forked from Supervisor/initscripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
opensuse-garymonson
executable file
·84 lines (77 loc) · 1.71 KB
/
opensuse-garymonson
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/bin/bash
#
# /etc/init.d/supervisord
# Handles starting and stopping supervisord.
#
# Tested on OpenSUSE 12.1, SLES 11 SP2
# Author: Gary Monson [email protected]
#
### BEGIN INIT INFO
# Provides: supervisord
# Required-Start: $local_fs $remote_fs $network
# Required-Stop: $local_fs $remote_fs $network
# Default-Start: 3 5
# Default-Stop: 0 1 2 6
# Description: Provides supervisord service
### END INIT INFO
DAEMON=/usr/local/bin/supervisord
BASE=`basename $DAEMON`
PIDFILE=/var/run/$BASE.pid
CONFIGFILE=/etc/$BASE.conf
LOGFILE=/var/log/$BASE/$BASE.log
# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0
start() {
echo -n "Starting supervisord: "
if [ -f $PIDFILE ]; then
PID=`cat $PIDFILE`
echo supervisord already running: $PID
exit 2;
else
mkdir -p `dirname $LOGFILE`
$DAEMON --pidfile $PIDFILE --configuration $CONFIGFILE --logfile $LOGFILE
RETVAL=$?
return $RETVAL
fi
}
stop() {
echo "Shutting down supervisord:"
killproc -p $PIDFILE supervisord
return 0
}
status() {
if [ -f $PIDFILE ]; then
PID=`cat $PIDFILE`
ps -p $PID >/dev/null 2>&1
if [ "$?" = 0 ]; then
echo "supervisord running"
exit 0
else
echo "pidfile exists ($PID), but supervisord not running"
exit 2
fi
else
echo "supervisord not running"
exit 1
fi
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
status)
status
;;
*)
echo "Usage: {start|stop|restart}"
exit 1
;;
esac
exit $?