forked from Supervisor/initscripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gentoo-matagus
55 lines (51 loc) · 1.51 KB
/
gentoo-matagus
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
#!/sbin/runscript
# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
#
# Author: Agustin Mendez ([email protected])
#
opts="${opts} "
pidfile="/var/run/supervisord/supervisord.pid"
fromcron="0"
# this next comment is important, don't remove it - it has to be somewhere in
# the init script to kill off a warning that doesn't apply to us
# svc_start svc_stop
checkconfig() {
if [[ -f "${pidfile}" ]] ; then
kill -0 $(< ${pidfile}) 2>/dev/null
if [[ $? -eq 0 ]] ; then
# the process exist, we have a problem
if [[ $fromcron -eq "0" ]] ; then
eerror "\"${pidfile}\" is still present and the process is running."
eerror "Please stop it \"kill $(< ${pidfile})\" maybe ?"
fi
return 1
else
rm -f "${pidfile}"
fi
fi
return 0
}
start() {
checkconfig || return 1
ebegin "Starting Supervisor Daemon"
/usr/bin/supervisord
eend $?
}
stop() {
ebegin "Stopping Supervisor Daemon"
local PID timeout=${STOPTIMEOUT:-"120"}
PID=$(< "${pidfile}" )
start-stop-daemon --quiet --stop --pidfile "${pidfile}" &
while [[ -n "$PID" ]] \
&& $( ps -Ao pid | grep -q "^ *$PID$" ) \
&& [[ "${timeout}" -ge 1 ]]
do
timeout=$(($timeout - 1))
sleep 1
done
[[ "${timeout}" -lt 1 ]] && retstatus=1
sleep 1
[[ "$retstatus" -eq 0 ]] && rm -f "$pidfile"
eend ${retstatus}
}