Skip to content

Instantly share code, notes, and snippets.

@idan
Created November 12, 2010 21:00
Show Gist options
  • Save idan/674678 to your computer and use it in GitHub Desktop.
Save idan/674678 to your computer and use it in GitHub Desktop.
def gunicorn_pid():
"""Gets the PID of a supervisord-managed gunicorn"""
result = sudo('supervisorctl status %s' % env.proj_name)
m = re.search(r'pid (?P<pid>\d+)', result)
if m:
return m.group('pid') or None
def gunicorn_hup():
"""Sends HUP to gunicorn in order to gracefully restart the servers"""
pid = gunicorn_pid()
if pid:
sudo('kill -HUP %s' % pid)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment