Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add updated init script for slackware #52

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 31 additions & 37 deletions slackware
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,66 +2,69 @@
# /etc/rc.d/rc.supervisord
#
# AUTHOR: Josh Jaques <[email protected]>
# MODIFIED-BY: Damian Zareba <[email protected]>
#
# 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
'start')
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
;;


Expand All @@ -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
}
;;

*)
Expand Down