Skip to content

Instantly share code, notes, and snippets.

@Rembane
Created June 18, 2013 09:43
Show Gist options
  • Select an option

  • Save Rembane/5804063 to your computer and use it in GitHub Desktop.

Select an option

Save Rembane/5804063 to your computer and use it in GitHub Desktop.
The script makes gunicorn restart all the workers.
#!/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