Created
July 10, 2022 21:03
-
-
Save msterhuj/06c8b439e46ddd765b4eb934373c25ab to your computer and use it in GitHub Desktop.
Hot reload for django when using gunicorn
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
from os import kill, getppid | |
from signal import SIGHUP | |
from django.http import JsonResponse | |
def reload(request): | |
""" | |
Restart all worker and master of gunicorn app | |
https://docs.gunicorn.org/en/stable/signals.html#reload-the-configuration | |
""" | |
kill(getppid(), SIGHUP) | |
return JsonResponse({'data':'restart master'}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment