9
0
Fork 0

debian: Create a pidfile and kill based on it

This commit is contained in:
Holger Hans Peter Freyther 2015-04-22 11:39:19 -04:00
parent 2f3f851357
commit 29f38d3240
1 changed files with 5 additions and 11 deletions

16
debian/osmo-stp.init vendored
View File

@ -45,7 +45,9 @@ do_start()
# 2 if daemon could not be started
start-stop-daemon --start --quiet --exec $DAEMON --test > /dev/null \
|| return 1
start-stop-daemon --start --quiet --background --exec $DAEMON -- \
start-stop-daemon --start --quiet --background \
--pidfile /var/run/$NAME.pid --make-pidfile \
--exec $DAEMON -- \
$DAEMON_ARGS \
|| return 2
# Add code here, if necessary, that waits for the process to be ready
@ -63,17 +65,9 @@ do_stop()
# 1 if daemon was already stopped
# 2 if daemon could not be stopped
# other if a failure occurred
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --name $NAME
start-stop-daemon --stop --pidfile /var/run/$NAME.pid --quiet --retry=TERM/30/KILL/5 --name $NAME
RETVAL="$?"
[ "$RETVAL" = 2 ] && return 2
# Wait for children to finish too if this is a daemon that forks
# and if the daemon is only ever run from this initscript.
# If the above conditions are not satisfied then add some other code
# that waits for the process to drop all resources that could be
# needed by services started subsequently. A last resort is to
# sleep for some time.
start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
[ "$?" = 2 ] && return 2
rm /var/run/$NAME.pid 2> /dev/null
return "$RETVAL"
}