Skip to content

Commit

Permalink
deferred django imports to fix gunicorn startup
Browse files Browse the repository at this point in the history
  • Loading branch information
moltob committed Mar 11, 2017
1 parent 6a4771e commit b10b3fa
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
8 changes: 7 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@ WORKDIR $bizwiz_appdir

# do not use shell form to have gunicorn start with PID 1 and handle TERM instead of shell
# docker stop --> SIGTERM to PID _1_ --> gunicorn graceful shutdown
ENTRYPOINT ["gunicorn", "--bind 0.0.0.0:80", "--access-logfile data/gunicorn-access.log", "--error-logfile data/gunicorn-error.log", "bwsite.wsgi"]
ENTRYPOINT [ \
"gunicorn", \
"--bind 0.0.0.0:80", \
"--access-logfile data/gunicorn-access.log", \
"--error-logfile data/gunicorn-error.log", \
"bwsite.wsgi" \
]

# install application
COPY . .
Expand Down
8 changes: 4 additions & 4 deletions bwsite/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
For more information on this file, see
https://docs.djangoproject.com/en/1.10/howto/deployment/wsgi/
"""

import logging
import os

from django.core.wsgi import get_wsgi_application

from bizwiz.version import BIZWIZ_VERSION

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "bwsite.settings")
application = get_wsgi_application()

# import _after_ django is initialized
import logging
from bizwiz.version import BIZWIZ_VERSION

_logger = logging.getLogger(__name__)
_logger.info('************************************************************************************')
_logger.info('* Starting Bizwiz, version %s' % BIZWIZ_VERSION)
Expand Down

0 comments on commit b10b3fa

Please sign in to comment.