Skip to content

Instantly share code, notes, and snippets.

@msterhuj
Created July 10, 2022 21:03
Show Gist options
  • Save msterhuj/06c8b439e46ddd765b4eb934373c25ab to your computer and use it in GitHub Desktop.
Save msterhuj/06c8b439e46ddd765b4eb934373c25ab to your computer and use it in GitHub Desktop.
Hot reload for django when using gunicorn
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