Skip to content

Instantly share code, notes, and snippets.

@sontek
Created November 14, 2011 00:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sontek/1362947 to your computer and use it in GitHub Desktop.
Save sontek/1362947 to your computer and use it in GitHub Desktop.
Run gunicorn webserver and kill its workers when finished.
#!/bin/bash
# run if user hits control-c
control_c()
{
echo "Oh no, exiting!"
for pid in $(cat gunicorn.pid)
do
echo "killing $pid"
kill -SIGKILL $pid
done
rm gunicorn.pid
exit $?
}
# trap keyboard interrupt (control-c)
trap control_c SIGINT
gunicorn -c reloader.py --workers=2 --worker-class=gevent --pid=gunicorn.pid devwsgi:app &
while true; do
:
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment