Skip to content

Instantly share code, notes, and snippets.

@f2face
Last active April 16, 2018 03:24
Show Gist options
  • Save f2face/45d5f55a17c3d22a5f63f1cb7d4768d9 to your computer and use it in GitHub Desktop.
Save f2face/45d5f55a17c3d22a5f63f1cb7d4768d9 to your computer and use it in GitHub Desktop.
Supervisord init script (with chkconfig support). Put this script in /etc/rc.d/init.d/supervisord
#!/bin/bash
# chkconfig: - 99 10
. /etc/rc.d/init.d/functions
DAEMON=/usr/bin/supervisord
PIDFILE=/var/run/supervisord.pid
[ -x "$DAEMON" ] || exit 0
start() {
echo -n "Starting supervisord: "
if [ -f $PIDFILE ]; then
PID=`cat $PIDFILE`
echo supervisord already running: $PID
exit 2;
else
daemon $DAEMON --pidfile=$PIDFILE -c /etc/supervisord.conf
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/supervisord
return $RETVAL
fi
}
stop() {
echo -n "Shutting down supervisord: "
echo
killproc -p $PIDFILE supervisord
echo
rm -f /var/lock/subsys/supervisord
return 0
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status supervisord
;;
restart)
stop
start
;;
*)
echo "Usage: {start|stop|status|restart}"
exit 1
;;
esac
exit $?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment