Skip to content

Instantly share code, notes, and snippets.

@saml
Created December 9, 2015 15:30
Show Gist options
  • Save saml/22c11ef1e812e7822d97 to your computer and use it in GitHub Desktop.
Save saml/22c11ef1e812e7822d97 to your computer and use it in GitHub Desktop.
#!/bin/bash
prog="supervisord"
prog_bin="/var/lib/flask/venv/bin/${prog}"
pidfile="/var/run/${prog}.pid"
lockfile="/var/lock/subsys/${prog}"
source /etc/init.d/functions
start() {
echo -n "Starting $prog: "
if [[ -f "$pidfile" ]]
then
echo "Already running: $(cat "$pidfile")"
exit 2
else
daemon --pidfile="$pidfile" "$prog_bin" -c "/var/lib/flask/mastermind/supervisord.conf"
retval=$?
echo
(( $retval == 0 )) && touch "$lockfile"
return $retval
fi
}
stop() {
echo -n "Stopping $prog: "
killproc -p "$pidfile" "$prog_bin"
retval=$?
echo
(( $retval == 0 )) && rm -f "$lockfile" "$pidfile"
}
restart() {
stop
start
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
status)
status -p "$pidfile" "$prog_bin"
;;
*)
echo "Usage: $prog start|stop|restart|status"
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment