-
Notifications
You must be signed in to change notification settings - Fork 0
/
supervisord
75 lines (61 loc) · 1.5 KB
/
supervisord
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
#!/bin/sh
# Supervisor init.d script for Amazon Linux AMI.
#
# Originally forked from: https://gist.github.com/mhayes/866900
#
# chkconfig: 2345 80 20
# description: Bring up/down supervisord service.
# processname: supervisord
# Source function library.
. /etc/rc.d/init.d/functions
PATH=$PATH:/usr/local/bin
NAME="supervisord"
CONFIGFILE="/etc/$NAME.conf"
PIDFILE="/tmp/$NAME.pid"
SOCKETFILE="/tmp/supervisor.sock"
DAEMON=$(which $NAME 2>/dev/null)
[[ -z $DAEMON ]] && DAEMON="/usr/local/bin/$NAME"
SUPERVISORCTL=$(which supervisorctl 2>/dev/null)
[[ -z $SUPERVISORCTL ]] && SUPERVISORCTL="/usr/local/bin/supervisorctl"
if [[ ! -x $DAEMON ]]; then
printf "$DAEMON: not found the command."
exit 255
fi
if [[ ! -x $SUPERVISORCTL ]]; then
printf "$SUPERVISORCTL: not found the command."
exit 255
fi
if [ -f /etc/default/supervisor ] ; then
printf "$DAEMON: sourcing /etc/default/supervisor\n"
. /etc/default/supervisor
fi
start () {
declare rc
printf "Starting $NAME: "
daemon "$DAEMON" -c "$CONFIGFILE"
rc=$?
printf "\n"
return $rc
}
stop () {
printf "Stopping $NAME: "
$SUPERVISORCTL shutdown
# make sure shutdown complete
while [[ 1 ]]; do
if [[ ! -f $PIDFILE && ! -S $SOCKETFILE ]]; then
break
fi
done
}
usage () {
printf "Usage: $0 {start|stop|status|restart}\n"
exit 255
}
case "$1" in
start) start ;;
stop) stop ;;
restart) stop; start ;;
status) status "$DAEMON" ;;
*) usage ;;
esac
exit