Package: conserver-server
Version: 8.2.1-1
Severity: important
Tags: patch

Dear Maintainer,

conserver-server fails to restart in most cases on a systemd enabled
system (default since Jessie). 

root@mgmt-fw2:~# systemctl restart conserver-server         
Job for conserver-server.service failed because the control process exited with 
error code.
See "systemctl status conserver-server.service" and "journalctl -xe" for 
details.

When you restart an LSB service in systemd it calls the init script with
stop. As soon as it returns, it calls it again with start.

In the stop action you do not wait for the daemon to exit, which can
take 1-2 seconds. So systemd tries to start a new daemon to early and
fails.

Note that the quick fix of using "--retry 5" in the start-stop-daemon
invocation does not help. At least on my systems there are two
conserverd processes started. The one whose pid is in the pidfile exits
quickly, but the second one takes a bit of time until it exits.

You worked around this in the native restart action with a sleep, but I
have seen cases where it took longer to exit.

The attached patch adds retry to the stop action, uses the executable
name instead of the pidfile (so it waits for all processes to finish)
and changes restart to call stop/start directly.

Bernhard
>From ed868b4712faa8706fcac4c5c9c3cd8f105c4f49 Mon Sep 17 00:00:00 2001
From: Bernhard Schmidt <bernhard.schm...@lrz.de>
Date: Fri, 20 Apr 2018 17:06:48 +0200
Subject: [PATCH] Make init.d stop action wait for all daemons to exit

---
 debian/conserver-server.init | 15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)

diff --git a/debian/conserver-server.init b/debian/conserver-server.init
index 1f8d702..4e5725a 100644
--- a/debian/conserver-server.init
+++ b/debian/conserver-server.init
@@ -52,7 +52,7 @@ case "$1" in
        ;;
   stop)
        echo -n "Stopping $DESC: "
-       start-stop-daemon --stop --oknodo --quiet --pidfile $PIDFILE
+       start-stop-daemon --stop --oknodo --quiet --exec $DAEMON --retry 5
        echo "$NAME."
        ;;
   status)
@@ -77,17 +77,8 @@ case "$1" in
        #       option to the "reload" entry above. If not, "force-reload" is
        #       just the same as "restart".
        #
-       echo -n "Restarting $DESC: "
-       start-stop-daemon --stop --oknodo --quiet --pidfile $PIDFILE
-       sleep 1
-       if [ "$ASROOT" ]; then
-               start-stop-daemon --background --start \
-                       --quiet --exec $DAEMON -- -d $OPTS
-       else
-               start-stop-daemon --chuid conservr --background --start \
-                       --quiet --exec $DAEMON -- -d $OPTS
-       fi
-       echo "$NAME."
+       $0 stop
+       $0 start
        ;;
   *)
        N=/etc/init.d/$NAME
-- 
2.17.0

Reply via email to