Created
March 12, 2014 20:46
-
-
Save ikudriavtsev/9515925 to your computer and use it in GitHub Desktop.
Graceful restart of gunicorn server
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
# the idea is taken from here: http://unicorn.bogomips.org/SIGNALS.html | |
import os | |
import signal | |
# first we need to get the master process id | |
# it might be stored in a .pid file, e.g. | |
# let's assume we have the id in `master_pid` | |
# sending USR2 signal to the master process, this will recreate the master process and the worker(s) | |
os.kill(master_pid, signal.SIGUSR2) | |
# sending WINCH signal to the old master process | |
# can be skipped if the process is not daemonized | |
os.kill(master_pid, signal.SIGWINCH) | |
# sending the QUIT signal to the old master process | |
os.kill(master_pid, signal.SIGQUIT) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment