Skip to content

Instantly share code, notes, and snippets.

@macta
Last active May 28, 2018 13:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save macta/0f30e73a6f5670f301795eacd25f6f0e to your computer and use it in GitHub Desktop.
Save macta/0f30e73a6f5670f301795eacd25f6f0e to your computer and use it in GitHub Desktop.
init script for supervisord that works on Ubuntu 16. You need to copy this into /etc/init.d. (See comment for more instructions)
#! /bin/bash -e
### BEGIN INIT INFO
# Provides: supervisor
# Required-Start: $remote_fs $network $named
# Required-Stop: $remote_fs $network $named
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start/stop supervisor
# Description: Start/stop supervisor daemon and its configured
# subprocesses.
### END INIT INFO
SUPERVISORD=/usr/local/bin/supervisord
PIDFILE=/tmp/supervisord.pid
OPTS="-c /etc/supervisord.conf"
test -x $SUPERVISORD || exit 0
. /lib/lsb/init-functions
export PATH="${PATH:+$PATH:}/usr/local/bin:/usr/sbin:/sbin"
case "$1" in
start)
log_begin_msg "Starting Supervisor daemon manager..."
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $SUPERVISORD -- $OPTS || log_end_msg 1
log_end_msg 0
;;
stop)
log_begin_msg "Stopping Supervisor daemon manager..."
start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE || log_end_msg 1
log_end_msg 0
;;
restart|reload|force-reload)
log_begin_msg "Restarting Supervisor daemon manager..."
start-stop-daemon --stop --quiet --oknodo --retry 30 --pidfile $PIDFILE
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $SUPERVISORD -- $OPTS || log_end_msg 1
log_end_msg 0
;;
*)
log_success_msg "Usage: /etc/init.d/supervisor
{start|stop|reload|force-reload|restart}"
exit 1
esac
exit 0
@macta
Copy link
Author

macta commented May 11, 2018

Copy the file into init.d then run:

sudo chmod +x /etc/init.d/supervisord
sudo update-rc.d supervisord defaults

sudo service supervisord start

@macta
Copy link
Author

macta commented May 28, 2018

In preference use systemd to this approach (see alternate gists)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment