On Fri 2018-08-17 15:48:32 +0000, Harald Jenny wrote:
> the stop action of the current initscript takes a long time to stop
> the daemon, please find attached a patch which makes stopping faster.

Do you know why it takes a long time to stop?  without this change, it's
using the standard do_stop_cmd from /lib/init/init-d-script, which would
be:

        start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 \
            $STOP_ARGS \
            ${PIDFILE:+--pidfile ${PIDFILE}} --name $NAME --exec $DAEMON
        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 \
            $STOP_ARGS \
            --exec $DAEMON
        [ "$?" = 2 ] && return 2
        # Many daemons don't delete their pidfiles when they exit.
        rm -f $PIDFILE
        return $RETVAL

But your patch suggests it should just use nsd-control:

> --- nsd_ORIG  2018-06-15 08:34:28.000000000 +0200
> +++ nsd_STOPPING      2018-08-12 21:34:16.223230246 +0200
> @@ -37,6 +37,18 @@
>      do_tmpfiles $(basename $0)
>  }
>  
> +do_stop_cmd() {
> +    nsd-control status >/dev/null 2>/dev/null
> +    if [ "$?" -ne "0" ]; then
> +        return 1
> +    fi
> +    nsd-control stop >/dev/null
> +    if [ "$?" -ne "0" ]; then
> +        return 2
> +    fi
> +    return 0
> +}
> +
>  do_reload() {
>      nsd-control reload >/dev/null
>      return $?

Is there a reason that we don't expect nsd to respond promptly to a
SIGTERM ?  If so, maybe that needs to be addressed directly, since other
supervision approaches are very likely to try to use SIGTERM to stop the
running daemon anyway.  Or, is the delay due to some other part of the
default do_stop_cmd in /lib/init/init-d-script?  feel free to reassign
this bug to sysvinit-utils if you think the problem is with the default
do_stop_cmd.

        --dkg

Attachment: signature.asc
Description: PGP signature

Reply via email to