Skip to content

Instantly share code, notes, and snippets.

@keenhenry
Forked from CMCDragonkai/supervisord.conf
Created June 15, 2017 13:28
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 keenhenry/0931d250766a7d4261d7c03bf4fe5e2a to your computer and use it in GitHub Desktop.
Save keenhenry/0931d250766a7d4261d7c03bf4fe5e2a to your computer and use it in GitHub Desktop.
Upstart: Upstart Init Script for Supervisord
# supervisord - Upstarts the supervisor as service
# Put this file into /etc/init/supervisord.conf
# sudo service supervisord start
# sudo service supervisord stop
# Service gets started as root
# Needs `pgrep` available to root
description "Supervisord - Upstart"
stop on runlevel [016]
kill timeout 8
respawn
# change this to the directory which hosts the supervisord conf file
chdir /
env DAEMON=supervisord
# due to forking bug https://bugs.launchpad.net/upstart/+bug/406397/ this hack needs to be done
# 1. starts the daemon and a sleep operation keeping up with the daemon
# 2. stop will stop the sleep operation and manually stop the daemon
pre-start script
exec $DAEMON
end script
script
sleepWhileAppIsUp(){
while pgrep $1 >/dev/null; do
sleep 1
done
}
sleepWhileAppIsUp $DAEMON
end script
post-stop script
if pgrep $DAEMON;
then
kill `pgrep $DAEMON`
fi
end script
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment