From e2ed2969e4149087dc5392cc3383c5714d12cdfa Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Fri, 1 Sep 2017 15:37:00 +0200 Subject: [PATCH] TT#18115 Call start-stop-daemon correctly We should pass the interpreter executable as --exec and the actual script to run as --startas, as documented in the man page. Otherwise start-stop-daemon will not be able to match the executable currently running, and will consider that the daemon is *not* running. Use --name to match on the process name. Change-Id: Icb7a608aaf2dd3d54083f77ed6df67a7dbecdb8d --- debian/ngcp-rate-o-mat.init | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/debian/ngcp-rate-o-mat.init b/debian/ngcp-rate-o-mat.init index bd15e1a..b0e672e 100644 --- a/debian/ngcp-rate-o-mat.init +++ b/debian/ngcp-rate-o-mat.init @@ -17,6 +17,7 @@ PATH=/sbin:/usr/sbin:/bin:/usr/bin DESC="rate-o-mat" NAME=rate-o-mat PACKAGE=ngcp-rate-o-mat +INTERP=/usr/bin/perl DAEMON=/usr/sbin/$NAME DAEMON_ARGS="" PIDFILE=/var/run/$NAME.pid @@ -69,10 +70,12 @@ do_start() # 0 if daemon has been started # 1 if daemon was already running # 2 if daemon could not be started - start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \ + start-stop-daemon --start --quiet --test \ + --pidfile $PIDFILE --exec $INTERP --name $NAME --startas $DAEMON >/dev/null \ || return 1 - start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \ - $DAEMON_ARGS \ + start-stop-daemon --start --quiet \ + --pidfile $PIDFILE --exec $INTERP --name $NAME --startas $DAEMON \ + -- $DAEMON_ARGS \ || return 2 # Add code here, if necessary, that waits for the process to be ready # to handle requests from services started subsequently which depend @@ -88,7 +91,8 @@ do_stop() # 0 if daemon has been stopped # 2 if daemon could not be stopped # other if a failure occurred - start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME + start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 \ + --pidfile $PIDFILE --exec $INTERP --name $NAME [ "$?" = 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. @@ -96,7 +100,8 @@ do_stop() # 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 + start-stop-daemon --stop --quiet --retry=0/30/KILL/5 --oknodo \ + --pidfile $PIDFILE --exec $INTERP --name $NAME RETVAL="$?" [ "$RETVAL" = 2 ] && return 2 # daemon doesn't delete its pidfile when it exits @@ -113,7 +118,8 @@ do_reload() { # restarting (for example, when it is sent a SIGHUP), # then implement that here. # - start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME + start-stop-daemon --stop --signal 1 --quiet \ + --pidfile $PIDFILE --exec $INTERP --name $NAME return 0 }