Created
June 18, 2013 09:43
-
-
Save Rembane/5804063 to your computer and use it in GitHub Desktop.
The script makes gunicorn restart all the workers.
This file contains hidden or 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
| #!/usr/bin/env python | |
| # Sends HUP to the parent Gunicorn | |
| import subprocess | |
| for row in subprocess.check_output('ps axo ppid,pid,comm | grep gunicorn', shell=True).splitlines(): | |
| parts = row.strip().split() | |
| if parts[0] == '1': # Parent | |
| subprocess.call(['kill', '-HUP', parts[1]]) | |
| print 'gunicorn is now reloading your code.' | |
| break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment