aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2015-04-22 11:39:19 -0400
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2015-04-22 11:39:19 -0400
commit29f38d3240aaba4ca0d6fac901089adaa75ebd3a (patch)
tree12993bd7a8ed49bde9ce2d0b5eb46eb13adee931
parent2f3f851357846eb66ee97ff7a2942ab94f7c9ab8 (diff)
debian: Create a pidfile and kill based on it
-rwxr-xr-xdebian/osmo-stp.init16
1 files changed, 5 insertions, 11 deletions
diff --git a/debian/osmo-stp.init b/debian/osmo-stp.init
index 8488505..1584fd3 100755
--- a/debian/osmo-stp.init
+++ b/debian/osmo-stp.init
@@ -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"
}