Created
October 28, 2015 11:14
-
-
Save dukebody/dc64c128c823f5349254 to your computer and use it in GitHub Desktop.
Fabric task to restart gunicorn without downtime, killing workers sequentially, sleeping in between to let new ones get ready.
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
@task | |
def reloadapp(sleep=5): | |
""" | |
Reloads lead-ratings app and the celery workers. | |
""" | |
supervisorctl = os.path.join(env.venv_path, 'bin', 'supervisorctl') | |
# kill all gunicorn master children, sleeping in between | |
master_pid = run('sudo %s pid app' % supervisorctl) | |
children = run('pgrep -P %s' % master_pid).split('\r\n') | |
for child in children: | |
time.sleep(sleep) | |
run('kill %s' % child) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment