[Pkg-haproxy-maintainers] Bug#804530: Bug#804530: Bug#804530: Bug#804530: haproxy: Ensure stop action works on pre-systemd versions of Debian (and Ubuntu)

Apollon Oikonomopoulos apoikos at debian.org
Mon Nov 9 13:09:38 UTC 2015

On 15:01 Mon 09 Nov     , Apollon Oikonomopoulos wrote:
> If we're going to support this, I would like to avoid parsing program 
> output. We could check the dpkg version (e.g. using dpkg 
> --compare-versions) and fall back to the kill loop if dpkg is older 
> than 1.17.6, or we could keep the loop as is but create a temporary 
> pidfile for each PID and pass the temporary pidfile to 
> start-stop-daemon with `--pidfile` instead of `--pid`. Both approaches 
> sound a bit hackish, but the second is probably less so.

IOW, something along these lines:

diff --git a/debian/haproxy.init b/debian/haproxy.init
index 35af505..2852efa 100644
--- a/debian/haproxy.init
+++ b/debian/haproxy.init
@@ -62,8 +62,10 @@ haproxy_stop()
        for pid in $(cat $PIDFILE); do
+               tmppid="$(mktemp)"
                start-stop-daemon --quiet --oknodo --stop \
-                       --retry 5 --pid $pid --exec $HAPROXY || ret=$?
+                       --retry 5 --pidfile "$tmppid" --exec $HAPROXY || ret=$?
+               rm -f "$tmppid"
        [ $ret -eq 0 ] && rm -f $PIDFILE

Note that s-s-d has a '--remove-pidfile' option, but this is again too new (>= 1.17.19).

More information about the Pkg-haproxy-maintainers mailing list