-
-
Save keenhenry/0931d250766a7d4261d7c03bf4fe5e2a to your computer and use it in GitHub Desktop.
Upstart: Upstart Init Script for Supervisord
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
# 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