diff options
Diffstat (limited to 'system/supervisor/rc.supervisord')
-rw-r--r-- | system/supervisor/rc.supervisord | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/system/supervisor/rc.supervisord b/system/supervisor/rc.supervisord new file mode 100644 index 0000000000..1fb7a4d5fe --- /dev/null +++ b/system/supervisor/rc.supervisord @@ -0,0 +1,104 @@ +#!/bin/sh +# /etc/rc.d/rc.supervisord +# +# AUTHOR: Josh Jaques <jjaques@gmail.com> +# +# Start/stop/restart supervisor in slackware. +# Specfically tested in v13.37 +# +# To make Supervisor start automatically at boot, make this +# file executable: chmod 755 /etc/rc.d/rc.supervisord + +# Time to wait between stop/start on a restart +SHUTDOWN_TIME=5 + +# Time to wait after a start before reporting success/fail +STARTUP_TIME=1 + +# Location of the pid file +PIDFILE=/var/run/supervisord.pid + +# Config of supervisor +CONFIG=/etc/supervisord.conf + +# Daemon to start +DAEMON=supervisord + +supervisord_start() +{ + $DAEMON -c $CONFIG -j $PIDFILE +} + + +supervisord_status() +{ + if [ -f $PIDFILE ] + then + pgrep $DAEMON | grep -f $PIDFILE > /dev/null 2>/dev/null + if [ $? -eq 0 ] + then + return 0 + else + return 1 + fi + else + return 1 + fi +} + + +supervisord_stop() +{ + kill $(cat $PIDFILE) +} + +case "$1" in + 'start') + echo -n "Starting..." + supervisord_start + sleep $STARTUP_TIME + supervisord_status && echo "DONE [PID: $(cat $PIDFILE)]" || echo "ERROR" + ;; + + 'status') + supervisord_status && echo "RUNNING [PID: $(cat $PIDFILE)]" || echo "STOPPED" + ;; + + + 'stop') + supervisord_status && { + echo -n "Stopping $(cat $PIDFILE)..." + supervisord_stop + sleep $SHUTDOWN_TIME + supervisord_status && echo "Failed" || echo "Success" + } || { + echo "Not Running..." + exit 1 + } + ;; + + 'restart') + supervisord_status && { + echo -n "Stopping $(cat $PIDFILE)..." + supervisord_stop + sleep $SHUTDOWN_TIME + supervisord_status && { + echo "Failed" + exit 1 + } || { + echo "Success" + } + } || { + echo "Not Running..." + exit 1 + } + echo -n "Starting..." + supervisord_start + sleep $STARTUP_TIME + supervisord_status && echo "DONE [PID: $(cat $PIDFILE)]" || echo "ERROR" + ;; + + *) + echo "Usage: $0 {start|stop|restart|status}" + ;; +esac |