]> git.pld-linux.org Git - projects/rc-scripts.git/commitdiff
killproc: retry when --waitfortime was specified
authorElan Ruusamäe <glen@delfi.ee>
Mon, 18 May 2015 09:34:45 +0000 (12:34 +0300)
committerElan Ruusamäe <glen@delfi.ee>
Mon, 18 May 2015 09:35:54 +0000 (12:35 +0300)
so services like ldap (using killproc --waitfortime 300 -TERM), would
wait for previous instance to be stopped

as TERM is default, ldap should not specify -TERM signal in fact.

also respect --waitname in ssd kill mode

lib/functions

index f74eb3e45dc67fa6c793ec6496c5b335f00ecee9..5bb35657fd6786262b9f5101113946e2ba97668c 100644 (file)
@@ -848,16 +848,25 @@ killproc() {
        # works only with pidfile
        if is_no "$RC_LOGGING" && [ "$pidfile" ]; then
                local sig=${killlevel:--TERM} retry
-               # retry only if signal is not specified,
+               # do not retry if signal is specified,
                # as otherwise impossible to send HUP if process pid stays in pidfile.
-               if [ "${killlevel+set}" = "set" ]; then
+               # however, do retry if --waitfortime was specified
+               if [ "${killlevel+set}" = "set" ] && [ -z "$waittime" ]; then
                        # if we send HUP it's ok if process does not die
                        retry="--oknodo"
                else
-                       retry="--retry ${sig#-}/10/${sig#-}/60/KILL/10"
+                       local waitretry
+                       : ${waittime=10}
+                       : ${waitretry=$(($waittime * 2))}
+
+                       # 1. kill with $sig, wait $delay
+                       # 2. kill with $sig, wait $waittime
+                       # 3. kill with KILL, wait $waitretry
+                       retry="--retry ${sig#-}/${delay}/${sig#-}/${waittime}/KILL/${waitretry}"
                fi
                /sbin/start-stop-daemon -q --stop \
                        $retry \
+                       ${waitname:+--name $waitname} \
                        -s ${sig#-} \
                        ${pidfile:+--pidfile $pidfile}
                result=$?
This page took 0.063672 seconds and 4 git commands to generate.