Skip to content

Commit 4738305

Browse files
committed
Wait for Nginx to stop before returning
Make the `nginx.gracefulstop` task poll for the Nginx process until it has exited, by default. This makes it safe to use as such: fab preview class:frontend nginx.gracefulstop sdo:reboot This behaviour can be disabled by passing a boolean argument: fab preview class:frontend nginx.gracefulstop:wait=False
1 parent 7c6ba7a commit 4738305

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

nginx.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
from fabric.api import *
22

33
@task
4-
def gracefulstop(*args):
4+
def gracefulstop(wait=True):
55
"""Gracefully shutdown Nginx by finishing any in-flight requests"""
66
sudo('nginx -s quit')
7+
8+
if wait:
9+
# Poll for Nginx, until it's no longer running.
10+
run('while pgrep nginx >/dev/null; do echo "Waiting for Nginx to exit.."; sleep 1; done')

0 commit comments

Comments
 (0)