├── centos-systemd-etcs ├── redhat-sysconfig-jkoppe ├── redhat-sysconfig-equeffelec ├── README.md ├── fedora-bmbouter ├── gentoo-matagus ├── opensuse-garymonson ├── slackware ├── redhat-init-equeffelec ├── redhat-init-jkoppe ├── redhat-init-mingalevme ├── debian-norrgard └── ubuntu /centos-systemd-etcs: -------------------------------------------------------------------------------- 1 | # supervisord service for systemd (CentOS 7.0+) 2 | # by ET-CS (https://github.com/ET-CS) 3 | [Unit] 4 | Description=Supervisor daemon 5 | 6 | [Service] 7 | Type=forking 8 | ExecStart=/usr/bin/supervisord 9 | ExecStop=/usr/bin/supervisorctl $OPTIONS shutdown 10 | ExecReload=/usr/bin/supervisorctl $OPTIONS reload 11 | KillMode=process 12 | Restart=on-failure 13 | RestartSec=42s 14 | 15 | [Install] 16 | WantedBy=multi-user.target 17 | -------------------------------------------------------------------------------- /redhat-sysconfig-jkoppe: -------------------------------------------------------------------------------- 1 | # this is sourced by the supervisord init script 2 | # written by jkoppe 3 | 4 | set -a 5 | 6 | # should probably put both of these options as runtime arguments 7 | OPTIONS="-c /etc/supervisord.conf" 8 | PIDFILE=/var/run/supervisord.pid 9 | 10 | # unset this variable if you don't care to wait for child processes to shutdown before removing the /var/lock/subsys/supervisord lock 11 | WAIT_FOR_SUBPROCESSES=yes 12 | 13 | # remove this if you manage number of open files in some other fashion 14 | ulimit -n 96000 15 | -------------------------------------------------------------------------------- /redhat-sysconfig-equeffelec: -------------------------------------------------------------------------------- 1 | # Configuration file for the supervisord service 2 | # 3 | # Author: Jason Koppe 4 | # orginal work 5 | # Erwan Queffelec 6 | # adjusted to new LSB-compliant init script 7 | 8 | # WARNING: change these wisely! for instance, adding -d, --nodaemon 9 | # here will lead to a very undesirable (blocking) behavior 10 | #OPTIONS="-c /etc/supervisord.conf" 11 | #PIDFILE=/var/run/supervisord.pid 12 | #LOCKFILE=/var/lock/subsys/supervisord.pid 13 | 14 | # Path to the supervisord binary 15 | #SUPERVISORD=/usr/bin/supervisord 16 | 17 | # How long should we wait before forcefully killing the supervisord process ? 18 | #STOP_TIMEOUT=60 19 | 20 | # Remove this if you manage number of open files in some other fashion 21 | ulimit -n 96000 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Init Scripts 2 | 3 | This repository contains user-contributed scripts for running 4 | [Supervisor](https://github.com/supervisor/supervisor) under 5 | various operating systems. If a script is not available for 6 | your favorite system, consider writing one. 7 | 8 | ## Contributing 9 | 10 | Fork the repository, add your well-tested script, then send a 11 | pull request. Please include your contact information in the 12 | script and clearly indicate what system(s) your script supports. 13 | 14 | ## Maintainers 15 | 16 | The Supervisor maintainers will occasionally merge pull requests but 17 | in general do not have enough bandwidth to test or maintain the scripts 18 | in this repository. 19 | 20 | If you are modifying an existing script, please make an attempt to 21 | discuss your change with the script's original author before opening 22 | a pull request. 23 | -------------------------------------------------------------------------------- /fedora-bmbouter: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # /etc/rc.d/init.d/supervisord 4 | # supervisord This shell script takes care of starting and stopping 5 | # supervisord. Tested on Fedora 11. 6 | # 7 | # Author: Brian Bouterse bmbouter@gmail.com 8 | # 9 | # chkconfig: 345 80 80 10 | # description: supervisord is a client/server process control system. \ 11 | # processname: supervisord 12 | # pidfile: /var/run/supervisord.pid 13 | 14 | # Source function library. 15 | . /etc/init.d/functions 16 | 17 | DAEMON=/usr/bin/supervisord 18 | PIDFILE=/var/run/supervisord.pid 19 | 20 | # Exit if the package is not installed 21 | [ -x "$DAEMON" ] || exit 0 22 | 23 | start() { 24 | echo -n "Starting supervisord: " 25 | if [ -f $PIDFILE ]; then 26 | PID=`cat $PIDFILE` 27 | echo supervisord already running: $PID 28 | exit 2; 29 | else 30 | daemon $DAEMON --pidfile=$PIDFILE 31 | RETVAL=$? 32 | echo 33 | [ $RETVAL -eq 0 ] && touch /var/lock/subsys/supervisord 34 | return $RETVAL 35 | fi 36 | 37 | } 38 | 39 | stop() { 40 | echo -n "Shutting down supervisord: " 41 | echo 42 | killproc -p $PIDFILE supervisord 43 | echo 44 | rm -f /var/lock/subsys/supervisord 45 | return 0 46 | } 47 | 48 | case "$1" in 49 | start) 50 | start 51 | ;; 52 | stop) 53 | stop 54 | ;; 55 | status) 56 | status supervisord 57 | ;; 58 | restart) 59 | stop 60 | start 61 | ;; 62 | *) 63 | echo "Usage: {start|stop|status|restart}" 64 | exit 1 65 | ;; 66 | esac 67 | exit $? 68 | -------------------------------------------------------------------------------- /gentoo-matagus: -------------------------------------------------------------------------------- 1 | #!/sbin/runscript 2 | # Copyright 1999-2005 Gentoo Foundation 3 | # Distributed under the terms of the GNU General Public License v2 4 | # 5 | # Author: Agustin Mendez (matagus@gmail.com) 6 | # 7 | 8 | opts="${opts} " 9 | pidfile="/var/run/supervisord/supervisord.pid" 10 | 11 | fromcron="0" 12 | # this next comment is important, don't remove it - it has to be somewhere in 13 | # the init script to kill off a warning that doesn't apply to us 14 | # svc_start svc_stop 15 | checkconfig() { 16 | if [[ -f "${pidfile}" ]] ; then 17 | kill -0 $(< ${pidfile}) 2>/dev/null 18 | if [[ $? -eq 0 ]] ; then 19 | # the process exist, we have a problem 20 | if [[ $fromcron -eq "0" ]] ; then 21 | eerror "\"${pidfile}\" is still present and the process is running." 22 | eerror "Please stop it \"kill $(< ${pidfile})\" maybe ?" 23 | fi 24 | return 1 25 | else 26 | rm -f "${pidfile}" 27 | fi 28 | fi 29 | return 0 30 | } 31 | 32 | start() { 33 | checkconfig || return 1 34 | ebegin "Starting Supervisor Daemon" 35 | /usr/bin/supervisord 36 | eend $? 37 | } 38 | 39 | stop() { 40 | ebegin "Stopping Supervisor Daemon" 41 | local PID timeout=${STOPTIMEOUT:-"120"} 42 | PID=$(< "${pidfile}" ) 43 | start-stop-daemon --quiet --stop --pidfile "${pidfile}" & 44 | while [[ -n "$PID" ]] \ 45 | && $( ps -Ao pid | grep -q "^ *$PID$" ) \ 46 | && [[ "${timeout}" -ge 1 ]] 47 | do 48 | timeout=$(($timeout - 1)) 49 | sleep 1 50 | done 51 | [[ "${timeout}" -lt 1 ]] && retstatus=1 52 | sleep 1 53 | [[ "$retstatus" -eq 0 ]] && rm -f "$pidfile" 54 | eend ${retstatus} 55 | } 56 | -------------------------------------------------------------------------------- /opensuse-garymonson: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # /etc/init.d/supervisord 4 | # Handles starting and stopping supervisord. 5 | # 6 | # Tested on OpenSUSE 12.1, SLES 11 SP2 7 | # Author: Gary Monson gary.monson@gmail.com 8 | # 9 | ### BEGIN INIT INFO 10 | # Provides: supervisord 11 | # Required-Start: $local_fs $remote_fs $network 12 | # Required-Stop: $local_fs $remote_fs $network 13 | # Default-Start: 3 5 14 | # Default-Stop: 0 1 2 6 15 | # Description: Provides supervisord service 16 | ### END INIT INFO 17 | 18 | DAEMON=/usr/local/bin/supervisord 19 | BASE=`basename $DAEMON` 20 | PIDFILE=/var/run/$BASE.pid 21 | CONFIGFILE=/etc/$BASE.conf 22 | LOGFILE=/var/log/$BASE/$BASE.log 23 | 24 | # Exit if the package is not installed 25 | [ -x "$DAEMON" ] || exit 0 26 | 27 | start() { 28 | echo -n "Starting supervisord: " 29 | if [ -f $PIDFILE ]; then 30 | PID=`cat $PIDFILE` 31 | echo supervisord already running: $PID 32 | exit 2; 33 | else 34 | mkdir -p `dirname $LOGFILE` 35 | $DAEMON --pidfile $PIDFILE --configuration $CONFIGFILE --logfile $LOGFILE 36 | RETVAL=$? 37 | return $RETVAL 38 | fi 39 | } 40 | 41 | stop() { 42 | echo "Shutting down supervisord:" 43 | killproc -p $PIDFILE supervisord 44 | return 0 45 | } 46 | 47 | status() { 48 | if [ -f $PIDFILE ]; then 49 | PID=`cat $PIDFILE` 50 | ps -p $PID >/dev/null 2>&1 51 | if [ "$?" = 0 ]; then 52 | echo "supervisord running" 53 | exit 0 54 | else 55 | echo "pidfile exists ($PID), but supervisord not running" 56 | exit 2 57 | fi 58 | else 59 | echo "supervisord not running" 60 | exit 1 61 | fi 62 | } 63 | 64 | case "$1" in 65 | start) 66 | start 67 | ;; 68 | stop) 69 | stop 70 | ;; 71 | restart) 72 | stop 73 | start 74 | ;; 75 | status) 76 | status 77 | ;; 78 | *) 79 | echo "Usage: {start|stop|restart}" 80 | exit 1 81 | ;; 82 | esac 83 | 84 | exit $? 85 | -------------------------------------------------------------------------------- /slackware: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # /etc/rc.d/rc.supervisord 3 | # 4 | # AUTHOR: Josh Jaques 5 | # 6 | # Start/stop/restart supervisor in slackware. 7 | # Specfically tested in v13.37 8 | # 9 | # To make Supervisor start automatically at boot, make this 10 | # file executable: chmod 755 /etc/rc.d/rc.supervisord 11 | 12 | # Time to wait between stop/start on a restart 13 | SHUTDOWN_TIME=5 14 | 15 | # Time to wait after a start before reporting success/fail 16 | STARTUP_TIME=1 17 | 18 | # Location of the pid file 19 | PIDFILE=/var/run/supervisord.pid 20 | 21 | # Config of supervisor 22 | CONFIG=/etc/supervisord.conf 23 | 24 | # Daemon to start 25 | DAEMON=supervisord 26 | 27 | supervisord_start() 28 | { 29 | $DAEMON -c $CONFIG -j $PIDFILE 30 | } 31 | 32 | 33 | supervisord_status() 34 | { 35 | if [ -f $PIDFILE ] 36 | then 37 | pgrep $DAEMON | grep -f $PIDFILE > /dev/null 2>/dev/null 38 | if [ $? -eq 0 ] 39 | then 40 | return 0 41 | else 42 | return 1 43 | fi 44 | else 45 | return 1 46 | fi 47 | } 48 | 49 | 50 | supervisord_stop() 51 | { 52 | kill $(cat $PIDFILE) 53 | } 54 | 55 | case "$1" in 56 | 'start') 57 | echo -n "Starting..." 58 | supervisord_start 59 | sleep $STARTUP_TIME 60 | supervisord_status && echo "DONE [PID: $(cat $PIDFILE)]" || echo "ERROR" 61 | ;; 62 | 63 | 'status') 64 | supervisord_status && echo "RUNNING [PID: $(cat $PIDFILE)]" || echo "STOPPED" 65 | ;; 66 | 67 | 68 | 'stop') 69 | supervisord_status && { 70 | echo -n "Stopping $(cat $PIDFILE)..." 71 | supervisord_stop 72 | sleep $SHUTDOWN_TIME 73 | supervisord_status && echo "Failed" || echo "Success" 74 | } || { 75 | echo "Not Running..." 76 | exit 1 77 | } 78 | ;; 79 | 80 | 'restart') 81 | supervisord_status && { 82 | echo -n "Stopping $(cat $PIDFILE)..." 83 | supervisord_stop 84 | sleep $SHUTDOWN_TIME 85 | supervisord_status && { 86 | echo "Failed" 87 | exit 1 88 | } || { 89 | echo "Success" 90 | } 91 | } || { 92 | echo "Not Running..." 93 | exit 1 94 | } 95 | echo -n "Starting..." 96 | supervisord_start 97 | sleep $STARTUP_TIME 98 | supervisord_status && echo "DONE [PID: $(cat $PIDFILE)]" || echo "ERROR" 99 | ;; 100 | 101 | *) 102 | echo "Usage: $0 {start|stop|restart|status}" 103 | ;; 104 | esac 105 | 106 | -------------------------------------------------------------------------------- /redhat-init-equeffelec: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # supervisord Startup script for the Supervisor process control system 4 | # 5 | # Author: Mike McGrath (based off yumupdatesd) 6 | # Jason Koppe adjusted to read sysconfig, 7 | # use supervisord tools to start/stop, conditionally wait 8 | # for child processes to shutdown, and startup later 9 | # Erwan Queffelec 10 | # make script LSB-compliant 11 | # Greg Smethells 12 | #. Allow supervisorctl to be overridden 13 | # 14 | # chkconfig: 345 83 04 15 | # description: Supervisor is a client/server system that allows \ 16 | # its users to monitor and control a number of processes on \ 17 | # UNIX-like operating systems. 18 | # processname: supervisord 19 | # config: /etc/supervisord.conf 20 | # config: /etc/sysconfig/supervisord 21 | # pidfile: /var/run/supervisord.pid 22 | # 23 | ### BEGIN INIT INFO 24 | # Provides: supervisord 25 | # Required-Start: $all 26 | # Required-Stop: $all 27 | # Short-Description: start and stop Supervisor process control system 28 | # Description: Supervisor is a client/server system that allows 29 | # its users to monitor and control a number of processes on 30 | # UNIX-like operating systems. 31 | ### END INIT INFO 32 | 33 | # Source function library 34 | . /etc/rc.d/init.d/functions 35 | 36 | # Source system settings 37 | if [ -f /etc/sysconfig/supervisord ]; then 38 | . /etc/sysconfig/supervisord 39 | fi 40 | 41 | # Path to the supervisorctl script, server binary, 42 | # and short-form for messages. 43 | supervisorctl=${SUPERVISORCTL-/usr/bin/supervisorctl} 44 | supervisord=${SUPERVISORD-/usr/bin/supervisord} 45 | prog=supervisord 46 | pidfile=${PIDFILE-/var/run/supervisord.pid} 47 | lockfile=${LOCKFILE-/var/lock/subsys/supervisord} 48 | sockfile=${SOCKFILE-/var/run/supervisord.sock} 49 | STOP_TIMEOUT=${STOP_TIMEOUT-60} 50 | OPTIONS="${OPTIONS--c /etc/supervisord.conf}" 51 | RETVAL=0 52 | 53 | start() { 54 | echo -n $"Starting $prog: " 55 | daemon --pidfile=${pidfile} $supervisord $OPTIONS 56 | RETVAL=$? 57 | echo 58 | if [ $RETVAL -eq 0 ]; then 59 | touch ${lockfile} 60 | $supervisorctl $OPTIONS status 61 | fi 62 | return $RETVAL 63 | } 64 | 65 | stop() { 66 | echo -n $"Stopping $prog: " 67 | killproc -p ${pidfile} -d ${STOP_TIMEOUT} $supervisord 68 | RETVAL=$? 69 | echo 70 | [ $RETVAL -eq 0 ] && rm -rf ${lockfile} ${pidfile} ${sockfile} 71 | } 72 | 73 | reload() { 74 | echo -n $"Reloading $prog: " 75 | LSB=1 killproc -p $pidfile $supervisord -HUP 76 | RETVAL=$? 77 | echo 78 | if [ $RETVAL -eq 7 ]; then 79 | failure $"$prog reload" 80 | else 81 | $supervisorctl $OPTIONS status 82 | fi 83 | } 84 | 85 | restart() { 86 | stop 87 | start 88 | } 89 | 90 | case "$1" in 91 | start) 92 | start 93 | ;; 94 | stop) 95 | stop 96 | ;; 97 | status) 98 | status -p ${pidfile} $supervisord 99 | RETVAL=$? 100 | [ $RETVAL -eq 0 ] && $supervisorctl $OPTIONS status 101 | ;; 102 | restart) 103 | restart 104 | ;; 105 | condrestart|try-restart) 106 | if status -p ${pidfile} $supervisord >&/dev/null; then 107 | stop 108 | start 109 | fi 110 | ;; 111 | force-reload|reload) 112 | reload 113 | ;; 114 | *) 115 | echo $"Usage: $prog {start|stop|restart|condrestart|try-restart|force-reload|reload}" 116 | RETVAL=2 117 | esac 118 | 119 | exit $RETVAL 120 | -------------------------------------------------------------------------------- /redhat-init-jkoppe: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # supervisord This scripts turns supervisord on 4 | # 5 | # Author: Mike McGrath (based off yumupdatesd) 6 | # Jason Koppe adjusted to read sysconfig, 7 | # use supervisord tools to start/stop, conditionally wait 8 | # for child processes to shutdown, and startup later 9 | # Cameron Kerr adjusted 'status' 10 | # to return an LSB-compliant return code so things like 11 | # Ansible will be able to idempotently ensure service is 12 | # up or down as desired. 13 | # 14 | # chkconfig: 345 83 04 15 | # 16 | # description: supervisor is a process control utility. It has a web based 17 | # xmlrpc interface as well as a few other nifty features. 18 | # processname: supervisord 19 | # config: /etc/supervisord.conf 20 | # pidfile: /var/run/supervisord.pid 21 | # 22 | 23 | # Treat unset variables as error 24 | set -o nounset 25 | 26 | # source function library 27 | . /etc/rc.d/init.d/functions 28 | 29 | # source system settings 30 | [ -e /etc/sysconfig/supervisord ] && . /etc/sysconfig/supervisord 31 | 32 | RETVAL=0 33 | 34 | start() { 35 | echo "Starting supervisord: " 36 | if [ -e $PIDFILE ]; then 37 | echo "ALREADY STARTED" 38 | return 1 39 | fi 40 | 41 | # start supervisord with options from sysconfig (stuff like -c) 42 | /usr/bin/supervisord $OPTIONS 43 | 44 | # show initial startup status 45 | /usr/bin/supervisorctl $OPTIONS status 46 | 47 | # only create the subsyslock if we created the PIDFILE 48 | [ -e $PIDFILE ] && touch /var/lock/subsys/supervisord 49 | } 50 | 51 | stop() { 52 | echo -n "Stopping supervisord: " 53 | /usr/bin/supervisorctl $OPTIONS shutdown 54 | if [ -n "$WAIT_FOR_SUBPROCESSES" ]; then 55 | echo "Waiting roughly 60 seconds for $PIDFILE to be removed after child processes exit" 56 | for sleep in 2 2 2 2 4 4 4 4 8 8 8 8 last; do 57 | if [ ! -e $PIDFILE ] ; then 58 | echo "Supervisord exited as expected in under $total_sleep seconds" 59 | break 60 | else 61 | if [[ $sleep -eq "last" ]] ; then 62 | echo "Supervisord still working on shutting down. We've waited roughly 60 seconds, we'll let it do its thing from here" 63 | return 1 64 | else 65 | sleep $sleep 66 | total_sleep=$(( $total_sleep + $sleep )) 67 | fi 68 | 69 | fi 70 | done 71 | fi 72 | 73 | # always remove the subsys. we might have waited a while, but just remove it at this point. 74 | rm -f /var/lock/subsys/supervisord 75 | } 76 | 77 | restart() { 78 | stop 79 | start 80 | } 81 | 82 | case "$1" in 83 | start) 84 | start 85 | RETVAL=$? 86 | ;; 87 | stop) 88 | stop 89 | RETVAL=$? 90 | ;; 91 | restart|force-reload) 92 | restart 93 | RETVAL=$? 94 | ;; 95 | reload) 96 | /usr/bin/supervisorctl $OPTIONS reload 97 | RETVAL=$? 98 | ;; 99 | condrestart) 100 | [ -f /var/lock/subsys/supervisord ] && restart 101 | RETVAL=$? 102 | ;; 103 | status) 104 | /usr/bin/supervisorctl $OPTIONS status 105 | status -p $PIDFILE supervisord 106 | # The 'status' option should return one of the LSB-defined return-codes, 107 | # in particular, return-code 3 should mean that the service is not 108 | # currently running. This is particularly important for Ansible's 'service' 109 | # module, as without this behaviour it won't know if a service is up or down. 110 | RETVAL=$? 111 | ;; 112 | *) 113 | echo $"Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart}" 114 | exit 1 115 | esac 116 | 117 | exit $RETVAL 118 | -------------------------------------------------------------------------------- /redhat-init-mingalevme: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # supervisord This scripts turns supervisord on 4 | # 5 | # Author: Mike McGrath (based off yumupdatesd) 6 | # Jason Koppe adjusted to read sysconfig, 7 | # use supervisord tools to start/stop, conditionally wait 8 | # for child processes to shutdown, and startup later 9 | # Mikhail Mingalev Merged 10 | # redhat-init-jkoppe and redhat-sysconfig-jkoppe, and 11 | # made the script "simple customizable". 12 | # Brendan Maguire Added OPTIONS to 13 | # SUPERVISORCTL status call 14 | # 15 | # chkconfig: 345 83 04 16 | # 17 | # description: supervisor is a process control utility. It has a web based 18 | # xmlrpc interface as well as a few other nifty features. 19 | # Script was originally written by Jason Koppe . 20 | # 21 | 22 | # source function library 23 | . /etc/rc.d/init.d/functions 24 | 25 | set -a 26 | 27 | PREFIX=/usr 28 | 29 | SUPERVISORD=$PREFIX/bin/supervisord 30 | SUPERVISORCTL=$PREFIX/bin/supervisorctl 31 | 32 | PIDFILE=/var/run/supervisord.pid 33 | LOCKFILE=/var/lock/subsys/supervisord 34 | 35 | OPTIONS="-c /etc/supervisord.conf" 36 | 37 | # unset this variable if you don't care to wait for child processes to shutdown before removing the $LOCKFILE-lock 38 | WAIT_FOR_SUBPROCESSES=yes 39 | 40 | # remove this if you manage number of open files in some other fashion 41 | ulimit -n 96000 42 | 43 | RETVAL=0 44 | 45 | 46 | running_pid() 47 | { 48 | # Check if a given process pid's cmdline matches a given name 49 | pid=$1 50 | name=$2 51 | [ -z "$pid" ] && return 1 52 | [ ! -d /proc/$pid ] && return 1 53 | (cat /proc/$pid/cmdline | tr "\000" "\n"|grep -q $name) || return 1 54 | return 0 55 | } 56 | 57 | running() 58 | { 59 | # Check if the process is running looking at /proc 60 | # (works for all users) 61 | 62 | # No pidfile, probably no daemon present 63 | [ ! -f "$PIDFILE" ] && return 1 64 | # Obtain the pid and check it against the binary name 65 | pid=`cat $PIDFILE` 66 | running_pid $pid $SUPERVISORD || return 1 67 | return 0 68 | } 69 | 70 | start() { 71 | echo "Starting supervisord: " 72 | 73 | if [ -e $PIDFILE ]; then 74 | echo "ALREADY STARTED" 75 | return 1 76 | fi 77 | 78 | # start supervisord with options from sysconfig (stuff like -c) 79 | $SUPERVISORD $OPTIONS 80 | 81 | # show initial startup status 82 | $SUPERVISORCTL $OPTIONS status 83 | 84 | # only create the subsyslock if we created the PIDFILE 85 | [ -e $PIDFILE ] && touch $LOCKFILE 86 | } 87 | 88 | stop() { 89 | echo -n "Stopping supervisord: " 90 | $SUPERVISORCTL $OPTIONS shutdown 91 | if [ -n "$WAIT_FOR_SUBPROCESSES" ]; then 92 | echo "Waiting roughly 60 seconds for $PIDFILE to be removed after child processes exit" 93 | for sleep in 2 2 2 2 4 4 4 4 8 8 8 8 last; do 94 | if [ ! -e $PIDFILE ] ; then 95 | echo "Supervisord exited as expected in under $total_sleep seconds" 96 | break 97 | else 98 | if [[ $sleep -eq "last" ]] ; then 99 | echo "Supervisord still working on shutting down. We've waited roughly 60 seconds, we'll let it do its thing from here" 100 | return 1 101 | else 102 | sleep $sleep 103 | total_sleep=$(( $total_sleep + $sleep )) 104 | fi 105 | 106 | fi 107 | done 108 | fi 109 | 110 | # always remove the subsys. We might have waited a while, but just remove it at this point. 111 | rm -f $LOCKFILE 112 | } 113 | 114 | restart() { 115 | stop 116 | start 117 | } 118 | 119 | case "$1" in 120 | start) 121 | start 122 | RETVAL=$? 123 | ;; 124 | stop) 125 | stop 126 | RETVAL=$? 127 | ;; 128 | restart|force-reload) 129 | restart 130 | RETVAL=$? 131 | ;; 132 | reload) 133 | $SUPERVISORCTL $OPTIONS reload 134 | RETVAL=$? 135 | ;; 136 | condrestart) 137 | [ -f $LOCKFILE ] && restart 138 | RETVAL=$? 139 | ;; 140 | status) 141 | $SUPERVISORCTL $OPTIONS status 142 | if running ; then 143 | RETVAL=0 144 | else 145 | RETVAL=1 146 | fi 147 | ;; 148 | *) 149 | echo $"Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart}" 150 | exit 1 151 | esac 152 | 153 | exit $RETVAL 154 | -------------------------------------------------------------------------------- /debian-norrgard: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | ### BEGIN INIT INFO 3 | # Provides: supervisord 4 | # Required-Start: $local_fs $remote_fs $networking 5 | # Required-Stop: $local_fs $remote_fs $networking 6 | # Default-Start: 2 3 4 5 7 | # Default-Stop: 0 1 6 8 | # Short-Description: Starts supervisord - see http://supervisord.org 9 | # Description: Starts and stops supervisord as needed - see http://supervisord.org 10 | ### END INIT INFO 11 | 12 | # Author: Leonard Norrgard 13 | # Version 1.0-alpha 14 | # Based on the /etc/init.d/skeleton script in Debian. 15 | 16 | # Please note: This script is not yet well tested. What little testing 17 | # that actually was done was only on supervisor 2.2b1. 18 | 19 | # Do NOT "set -e" 20 | 21 | # PATH should only include /usr/* if it runs after the mountnfs.sh script 22 | PATH=/sbin:/usr/sbin:/bin:/usr/bin 23 | DESC="Run a set of applications as daemons." 24 | NAME=supervisord 25 | DAEMON=/usr/bin/$NAME # Supervisord is installed in /usr/bin by default, but /usr/sbin would make more sense. 26 | SUPERVISORCTL=/usr/bin/supervisorctl 27 | PIDFILE=/var/run/$NAME.pid 28 | DAEMON_ARGS="--pidfile ${PIDFILE}" 29 | SCRIPTNAME=/etc/init.d/$NAME 30 | 31 | # Exit if the package is not installed 32 | [ -x "$DAEMON" ] || exit 0 33 | 34 | # Read configuration variable file if it is present 35 | [ -r /etc/default/$NAME ] && . /etc/default/$NAME 36 | 37 | # Load the VERBOSE setting and other rcS variables 38 | . /lib/init/vars.sh 39 | 40 | # Define LSB log_* functions. 41 | # Depend on lsb-base (>= 3.0-6) to ensure that this file is present. 42 | . /lib/lsb/init-functions 43 | 44 | # 45 | # Function that starts the daemon/service 46 | # 47 | do_start() 48 | { 49 | # Return 50 | # 0 if daemon has been started 51 | # 1 if daemon was already running 52 | # 2 if daemon could not be started 53 | [ -e $PIDFILE ] && return 1 54 | 55 | start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \ 56 | $DAEMON_ARGS \ 57 | || return 2 58 | # Add code here, if necessary, that waits for the process to be ready 59 | # to handle requests from services started subsequently which depend 60 | # on this one. As a last resort, sleep for some time. 61 | } 62 | 63 | # 64 | # Function that stops the daemon/service 65 | # 66 | do_stop() 67 | { 68 | # Return 69 | # 0 if daemon has been stopped 70 | # 1 if daemon was already stopped 71 | # 2 if daemon could not be stopped 72 | # other if a failure occurred 73 | [ -e $PIDFILE ] || return 1 74 | 75 | # Stop all processes under supervisord control. 76 | $SUPERVISORCTL stop all 77 | 78 | start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME 79 | RETVAL="$?" 80 | [ "$RETVAL" = 2 ] && return 2 81 | # Wait for children to finish too if this is a daemon that forks 82 | # and if the daemon is only ever run from this initscript. 83 | # If the above conditions are not satisfied then add some other code 84 | # that waits for the process to drop all resources that could be 85 | # needed by services started subsequently. A last resort is to 86 | # sleep for some time. 87 | start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON 88 | [ "$?" = 2 ] && return 2 89 | # Many daemons don't delete their pidfiles when they exit. 90 | rm -f $PIDFILE 91 | return "$RETVAL" 92 | } 93 | 94 | # 95 | # Function that sends a SIGHUP to the daemon/service 96 | # 97 | do_reload() { 98 | # 99 | # If the daemon can reload its configuration without 100 | # restarting (for example, when it is sent a SIGHUP), 101 | # then implement that here. 102 | # 103 | start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME 104 | return 0 105 | } 106 | 107 | case "$1" in 108 | start) 109 | [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME" 110 | do_start 111 | case "$?" in 112 | 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; 113 | 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; 114 | esac 115 | ;; 116 | stop) 117 | [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" 118 | do_stop 119 | case "$?" in 120 | 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; 121 | 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; 122 | esac 123 | ;; 124 | #reload|force-reload) 125 | # 126 | # If do_reload() is not implemented then leave this commented out 127 | # and leave 'force-reload' as an alias for 'restart'. 128 | # 129 | #log_daemon_msg "Reloading $DESC" "$NAME" 130 | #do_reload 131 | #log_end_msg $? 132 | #;; 133 | restart|force-reload) 134 | # 135 | # If the "reload" option is implemented then remove the 136 | # 'force-reload' alias 137 | # 138 | log_daemon_msg "Restarting $DESC" "$NAME" 139 | do_stop 140 | case "$?" in 141 | 0|1) 142 | do_start 143 | case "$?" in 144 | 0) log_end_msg 0 ;; 145 | 1) log_end_msg 1 ;; # Old process is still running 146 | *) log_end_msg 1 ;; # Failed to start 147 | esac 148 | ;; 149 | *) 150 | # Failed to stop 151 | log_end_msg 1 152 | ;; 153 | esac 154 | ;; 155 | *) 156 | #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2 157 | echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2 158 | exit 3 159 | ;; 160 | esac 161 | 162 | : 163 | -------------------------------------------------------------------------------- /ubuntu: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # 3 | # Downloaded from: 4 | # http://bazaar.launchpad.net/~ubuntu-branches/ubuntu/trusty/supervisor/trusty/view/head:/debian/supervisor.init 5 | # 6 | # skeleton example file to build /etc/init.d/ scripts. 7 | # This file should be used to construct scripts for /etc/init.d. 8 | # 9 | # Written by Miquel van Smoorenburg . 10 | # Modified for Debian 11 | # by Ian Murdock . 12 | # Further changes by Javier Fernandez-Sanguino 13 | # Modified by sbilly Added supervisorctl to status 14 | # 15 | # Version: @(#)skeleton 1.9 26-Feb-2001 miquels@cistron.nl 16 | # 17 | ### BEGIN INIT INFO 18 | # Provides: supervisor 19 | # Required-Start: $remote_fs $network $named 20 | # Required-Stop: $remote_fs $network $named 21 | # Default-Start: 2 3 4 5 22 | # Default-Stop: 0 1 6 23 | # Short-Description: Start/stop supervisor 24 | # Description: Start/stop supervisor daemon and its configured 25 | # subprocesses. 26 | ### END INIT INFO 27 | 28 | . /lib/lsb/init-functions 29 | 30 | PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin 31 | DAEMON=/usr/bin/supervisord 32 | SUPERVISORCTL=/usr/bin/supervisorctl 33 | NAME=supervisord 34 | DESC=supervisor 35 | 36 | test -x $DAEMON || exit 0 37 | 38 | LOGDIR=/var/log/supervisor 39 | PIDFILE=/var/run/$NAME.pid 40 | DODTIME=5 # Time to wait for the server to die, in seconds 41 | # If this value is set too low you might not 42 | # let some servers to die gracefully and 43 | # 'restart' will not work 44 | 45 | # Include supervisor defaults if available 46 | if [ -f /etc/default/supervisor ] ; then 47 | . /etc/default/supervisor 48 | fi 49 | DAEMON_OPTS="-c /etc/supervisor/supervisord.conf $DAEMON_OPTS" 50 | 51 | set -e 52 | 53 | running_pid() 54 | { 55 | # Check if a given process pid's cmdline matches a given name 56 | pid=$1 57 | name=$2 58 | [ -z "$pid" ] && return 1 59 | [ ! -d /proc/$pid ] && return 1 60 | (cat /proc/$pid/cmdline | tr "\000" "\n"|grep -q $name) || return 1 61 | return 0 62 | } 63 | 64 | running() 65 | { 66 | # Check if the process is running looking at /proc 67 | # (works for all users) 68 | 69 | # No pidfile, probably no daemon present 70 | [ ! -f "$PIDFILE" ] && return 1 71 | # Obtain the pid and check it against the binary name 72 | pid=`cat $PIDFILE` 73 | running_pid $pid $DAEMON || return 1 74 | return 0 75 | } 76 | 77 | force_stop() { 78 | # Forcefully kill the process 79 | [ ! -f "$PIDFILE" ] && return 80 | if running ; then 81 | kill -15 $pid 82 | # Is it really dead? 83 | [ -n "$DODTIME" ] && sleep "$DODTIME"s 84 | if running ; then 85 | kill -9 $pid 86 | [ -n "$DODTIME" ] && sleep "$DODTIME"s 87 | if running ; then 88 | echo "Cannot kill $NAME (pid=$pid)!" 89 | exit 1 90 | fi 91 | fi 92 | fi 93 | rm -f $PIDFILE 94 | return 0 95 | } 96 | 97 | case "$1" in 98 | start) 99 | echo -n "Starting $DESC: " 100 | start-stop-daemon --start --quiet --pidfile $PIDFILE \ 101 | --startas $DAEMON -- $DAEMON_OPTS 102 | test -f $PIDFILE || sleep 1 103 | if running ; then 104 | echo "$NAME." 105 | else 106 | echo " ERROR." 107 | fi 108 | ;; 109 | stop) 110 | echo -n "Stopping $DESC: " 111 | start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE 112 | echo "$NAME." 113 | ;; 114 | force-stop) 115 | echo -n "Forcefully stopping $DESC: " 116 | force_stop 117 | if ! running ; then 118 | echo "$NAME." 119 | else 120 | echo " ERROR." 121 | fi 122 | ;; 123 | #reload) 124 | # 125 | # If the daemon can reload its config files on the fly 126 | # for example by sending it SIGHUP, do it here. 127 | # 128 | # If the daemon responds to changes in its config file 129 | # directly anyway, make this a do-nothing entry. 130 | # 131 | # echo "Reloading $DESC configuration files." 132 | # start-stop-daemon --stop --signal 1 --quiet --pidfile \ 133 | # /var/run/$NAME.pid --exec $DAEMON 134 | #;; 135 | force-reload) 136 | # 137 | # If the "reload" option is implemented, move the "force-reload" 138 | # option to the "reload" entry above. If not, "force-reload" is 139 | # just the same as "restart" except that it does nothing if the 140 | # daemon isn't already running. 141 | # check wether $DAEMON is running. If so, restart 142 | start-stop-daemon --stop --test --quiet --pidfile $PIDFILE \ 143 | --startas $DAEMON \ 144 | && $0 restart \ 145 | || exit 0 146 | ;; 147 | restart) 148 | echo -n "Restarting $DESC: " 149 | start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE 150 | [ -n "$DODTIME" ] && sleep $DODTIME 151 | start-stop-daemon --start --quiet --pidfile $PIDFILE \ 152 | --startas $DAEMON -- $DAEMON_OPTS 153 | echo "$NAME." 154 | ;; 155 | status) 156 | echo -n "$NAME is " 157 | if running ; then 158 | echo "running" 159 | else 160 | echo " not running." 161 | exit 1 162 | fi 163 | $SUPERVISORCTL $DAEMON_OPTS status 164 | ;; 165 | *) 166 | N=/etc/init.d/$NAME 167 | # echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2 168 | echo "Usage: $N {start|stop|restart|force-reload|status|force-stop}" >&2 169 | exit 1 170 | ;; 171 | esac 172 | 173 | exit 0 174 | --------------------------------------------------------------------------------