summaryrefslogtreecommitdiff
path: root/system/supervisor/rc.supervisord
diff options
context:
space:
mode:
authordigwtx <wtx358@qq.com>2014-08-31 18:17:25 +0700
committerWilly Sudiarto Raharjo <willysr@slackbuilds.org>2014-08-31 18:17:25 +0700
commit01c299573cd04fcc3b7612ce8f18459bcf77bf19 (patch)
tree5e75ad79dd7b53283499d37bbbf05f2a9a67ade4 /system/supervisor/rc.supervisord
parent5a94f78d0a2542e4903b61c9ff7ee833b60fb83b (diff)
downloadslackbuilds-01c299573cd04fcc3b7612ce8f18459bcf77bf19.tar.gz
system/supervisor: Added (A system for controlling process state).
Signed-off-by: Willy Sudiarto Raharjo <willysr@slackbuilds.org>
Diffstat (limited to 'system/supervisor/rc.supervisord')
-rw-r--r--system/supervisor/rc.supervisord104
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