up vote 15 down vote favorite
15
share [g+] share [fb]

Supervisord does not come with an init script or does not indicate how to get it started automatically, ie. after a reboot. I've tried some user-contributed /etc/init.d scripts, but they all fail.

What would be the preferred solution ?

link|improve this question
how do you mean "fail" ? btw; this question seems to be belong on serverfault. – erenon Dec 21 '09 at 22:57
feedback

migrated from stackoverflow.com Dec 21 '09 at 23:00

This question came from our site for professional and enthusiast programmers.

7 Answers

Actually, I found one that works here http://gist.github.com/176149. To install it:

sudo curl http://gist.github.com/raw/176149/88d0d68c4af22a7474ad1d011659ea2d27e35b8d/supervisord.sh > /etc/init.d/supervisord
sudo chmod +x /etc/init.d/supervisord

to run it

sudo chmod +x /etc/init.d/supervisord

and to automatically schedule it, do

sudo update-rc.d supervisord defaults

however the "stop" argument does not work properly, but it's not such a big deal.

link|improve this answer
feedback

This is what I use on RHEL 5.4 and CentOS 5.5

I'm not sure wether it's depending on some configuration settings in my supervisord.conf. But it seems to work OK.

You need to run the following command after installing it

chkconfig --add supervisord

[/etc/rc.d/init.d/supervisord]

#!/bin/sh
#
# /etc/rc.d/init.d/supervisord
#
# Supervisor is a client/server system that
# allows its users to monitor and control a
# number of processes on UNIX-like operating
# systems.
#
# chkconfig: - 64 36
# description: Supervisor Server
# processname: supervisord

# Source init functions
. /etc/rc.d/init.d/functions

prog="supervisord"

prefix="/usr/"
exec_prefix="${prefix}"
prog_bin="${exec_prefix}/bin/supervisord"
PIDFILE="/var/run/$prog.pid"

start()
{
        echo -n $"Starting $prog: "
        daemon $prog_bin --pidfile $PIDFILE
        [ -f $PIDFILE ] && success $"$prog startup" || failure $"$prog startup"
        echo
}

stop()
{
        echo -n $"Shutting down $prog: "
        [ -f $PIDFILE ] && killproc $prog || success $"$prog shutdown"
        echo
}

case "$1" in

  start)
    start
  ;;

  stop)
    stop
  ;;

  status)
        status $prog
  ;;

  restart)
    stop
    start
  ;;

  *)
    echo "Usage: $0 {start|stop|restart|status}"
  ;;

esac
link|improve this answer
feedback

I created an upstart script for ubuntu 9.10

For example I installed supervisor into a virtual environment, then start and control supervisor from upstart.

create a text file /etc/init/supervisord.conf

the contents are:

description     "supervisord"

start on runlevel [345]
stop on runlevel [!345]

expect fork
respawn

exec /misc/home/bkc/Python_Environments/java2/supervisord/bin/supervisord -c /misc/home/bkc/Python_Environments/java2/supervisord/work/supervisord.conf

It will automatically start supervisor on boot. To manually start after creating the .conf file, use

sudo start supervisord

To manually stop the service, use

sudo stop supervisord

link|improve this answer
Thanks! Here is a one-liner: curl -L https://gist.github.com/raw/1213031/929e578faae2ad3bcb29b03d116bcb09e1932221/sup‌​‌​ervisord.conf > /etc/init/supervisord.conf && start supervisord (you need to be root) – charlax Sep 16 '11 at 17:48
feedback

There is a debian/ubuntu script in official supervisor svn repo:

http://svn.supervisord.org/initscripts/debian-norrgard

link|improve this answer
sorry, the SVN is no longer there. Is there an alternate location? – Alister Bulman Mar 30 '11 at 11:57
Yep -- it's all been moved to GitHub: github.com/Supervisor/initscripts – fish2000 Aug 1 '11 at 2:12
feedback

I added this lines into /etc/init.d/supervisord to fix "stop" argument processing:

do_stop()
{
    /usr/local/bin/supervisorctl stop all
    /usr/local/bin/supervisorctl shutdown
    # Return
    ...

and this works great for me.

link|improve this answer
feedback

This is working for me on Ubuntu 10.04.3 LTS:

Add the following to /etc/init.d/supervisord

#! /bin/bash -e

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 /var/run/sshd.pid --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

Then run:

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

sudo service supervisord start

None of the other answers worked for me.

link|improve this answer
feedback

Supervisor appears to now be in apt repository, so it shouldn't be necessary to hand-craft init files, just:

sudo apt-get install supervisor

You may want to first clean out (and backup) your old files prior to installation.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown