Skip to content

Instantly share code, notes, and snippets.

@RoboTeddy
Created August 12, 2012 04:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RoboTeddy/bb349098a1b4f6fb577a to your computer and use it in GitHub Desktop.
Save RoboTeddy/bb349098a1b4f6fb577a to your computer and use it in GitHub Desktop.
description "Python Application Worker"
stop on stopping python-application
respawn
instance $PORT
chdir {{ chdir }}
# run as user
exec su -s /bin/sh -c 'exec "$0" "$@"' {{ runas }} -- {{ python }} -u {{ script }} -p $PORT
description "Python Application"
start on runlevel [2345]
stop on runlevel [!2345]
# normally this sort've thing would have a 'task' stanza, but see [1]
#task
script
for i in `seq {{ first_port }} {{ last_port }}`; do
start python-application-worker PORT=$i || true
done
# [1] hang forever so that when we stop, we emit a stopping event, and our
# workers know to stop themselves
while true
do
sleep 100
done
end script
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment