Skip to content

Instantly share code, notes, and snippets.

@mamemomonga
Forked from keimlink/gist:831633
Last active July 9, 2021 18:02
Show Gist options
  • Save mamemomonga/4565e0fad9b9090b6312 to your computer and use it in GitHub Desktop.
Save mamemomonga/4565e0fad9b9090b6312 to your computer and use it in GitHub Desktop.
/etc/rc.d/init.d/supervisord for CentOS 6
#!/bin/bash
#
# Startup script for the Supervisor server
#
# Tested with CentOS release 6.6
#
# chkconfig: 2345 85 15
# description: Supervisor is a client/server system that allows its users to \
# monitor and control a number of processes on UNIX-like \
# operating systems.
#
# processname: supervisord
# pidfile: /var/run/supervisord.pid
# Source function library.
. /etc/rc.d/init.d/functions
RETVAL=0
prog="supervisord"
SUPERVISORD=/usr/bin/supervisord
PID_FILE=/var/run/supervisord.pid
CONFIG_FILE=/etc/supervisord.conf
start()
{
echo -n $"Starting $prog: "
$SUPERVISORD -c $CONFIG_FILE --pidfile $PID_FILE && success || failure
RETVAL=$?
echo
return $RETVAL
}
stop()
{
echo -n $"Stopping $prog: "
killproc -p $PID_FILE -d 10 $SUPERVISORD
RETVAL=$?
echo
}
reload()
{
echo -n $"Reloading $prog: "
if [ -n "`pidfileofproc $SUPERVISORD`" ] ; then
killproc $SUPERVISORD -HUP
else
# Fails if the pid file does not exist BEFORE the reload
failure $"Reloading $prog"
fi
sleep 1
if [ ! -e $PID_FILE ] ; then
# Fails if the pid file does not exist AFTER the reload
failure $"Reloading $prog"
fi
RETVAL=$?
echo
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
reload)
reload
;;
status)
status -p $PID_FILE $SUPERVISORD
RETVAL=$?
;;
*)
echo $"Usage: $0 {start|stop|restart|reload|status}"
RETVAL=1
esac
exit $RETVAL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment