diff --git a/slackware b/slackware old mode 100644 new mode 100755 index 7a40dab..3a193c5 --- a/slackware +++ b/slackware @@ -2,54 +2,57 @@ # /etc/rc.d/rc.supervisord # # AUTHOR: Josh Jaques +# MODIFIED-BY: Damian Zareba # # Start/stop/restart supervisor in slackware. -# Specfically tested in v13.37 +# +# Tested on -current as of 2022-11-01 # # To make Supervisor start automatically at boot, make this -# file executable: chmod 755 /etc/rc.d/rc.supervisord +# file executable: chmod +x /etc/rc.d/rc.supervisord # Time to wait between stop/start on a restart -SHUTDOWN_TIME=5 +SHUTDOWN_TIME=3 # Time to wait after a start before reporting success/fail -STARTUP_TIME=1 +STARTUP_TIME=2 # Location of the pid file PIDFILE=/var/run/supervisord.pid # Config of supervisor -CONFIG=/etc/supervisord.conf +CONFIG=/etc/supervisor/supervisord.conf # Daemon to start -DAEMON=supervisord +DAEMON=/usr/bin/supervisord supervisord_start() { - $DAEMON -c $CONFIG -j $PIDFILE + if [ -f $PIDFILE ] + then + rm $PIDFILE + fi + $DAEMON -c $CONFIG } 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 + if [ -n $(pgrep $DAEMON > /dev/null) ] && [ -f $PIDFILE ] + then + echo "Running [PID: $(cat $PIDFILE)]" + return 0 + else + echo "Not running" + return 1 + fi } supervisord_stop() { - kill $(cat $PIDFILE) + kill $(cat $PIDFILE) | pkill $DAEMON + rm $PIDFILE } case "$1" in @@ -57,11 +60,11 @@ case "$1" in echo -n "Starting..." supervisord_start sleep $STARTUP_TIME - supervisord_status && echo "DONE [PID: $(cat $PIDFILE)]" || echo "ERROR" + supervisord_status ;; 'status') - supervisord_status && echo "RUNNING [PID: $(cat $PIDFILE)]" || echo "STOPPED" + supervisord_status ;; @@ -78,24 +81,15 @@ case "$1" in ;; 'restart') - supervisord_status && { + 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 -n "Starting..." + supervisord_start + sleep $STARTUP_TIME + supervisord_status +} ;; *)