Created
October 17, 2016 20:51
-
-
Save sethrh/88197de55a3c2af09e138ca1be22806f to your computer and use it in GitHub Desktop.
UWSGI + Django, reload on code change
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from django.core.wsgi import get_wsgi_application | |
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "your-project.settings") | |
application = get_wsgi_application() | |
try: | |
import uwsgi | |
from uwsgidecorators import timer | |
from django.utils import autoreload | |
@timer(3) | |
def change_code_graceful_reload(sig): | |
if autoreload.code_changed(): | |
uwsgi.reload() | |
except ImportError: | |
# not running under uwsgi | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment