[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Faster shutdown and the ubuntu "multiuser" update-rc.d extention

[Gabor Gombas]
> That may be a good safety measure. I think it is really hard to hit
> the 5 second limit but when that happens it is very hard to diagnose
> later what went wrong. So if we can increase the max. timeout
> without imposing a real delay in the common case (i.e. when
> everything shuts down properly) that's good.

I increased it to 10 seconds in svn.  Not sure how high it should be
set by default, but doubling it seem safe enough.

> Also, how about doing a sync before sending the signals? That way
> I/O generated by the services that _do_ have a proper shutdown
> script won't interfere with killing the "trivial" services. Sure,
> that sync can take time, but then the final sync will be that much
> shorter.

Good idea.  Will commit.  

Also, it is fairly trivial to detect and report if SIGKILL is needed.
Here is a patch to implement all of these changes.  The SIGKILL
detection and reporting code is not tested.  Please provide feedback.
If it work, I'll include it in the next initscripts upload.  The boot
system is being discussed on
pkg-sysvinit-devel@lists.alioth.debian.org and on the #pkg-sysvinit
IRC channel on irc.debian.org, if you want to reach the maintainers

Index: debian/initscripts/etc/init.d/sendsigs
--- debian/initscripts/etc/init.d/sendsigs      (revision 1184)
+++ debian/initscripts/etc/init.d/sendsigs      (working copy)
@@ -22,23 +22,38 @@

+       # Flush the kernel I/O buffer before we start to kill
+       # processes, to make sure the IO of alrady stopped services to
+       # not slow down the remaining processes to a point where they
+       # are accidentily killed with SIGKILL because they did not
+       # manage to shut down in time.
+       sync
        # Kill all processes.
        log_action_begin_msg "Asking all remaining processes to terminate"
        killall5 -15 $OMITPIDS # SIGTERM
        log_action_end_msg 0
-       for seq in 1 2 3 4 5 ; do
+       for seq in 1 2 3 4 5 6 7 8 9 10; do
                # use SIGCONT/signal 18 to check if there are
                # processes left.  No need to check the exit code
                # value, because either killall5 work and it make
                # sense to wait for processes to die, or it fail and
                # there is nothing to wait for.
-               killall5 -18 $OMITPIDS || break
+               if killall5 -18 $OMITPIDS ; then
+                   :
+               else
+                   alldead=1
+                   break
+               fi

                sleep 1
-       log_action_begin_msg "Killing all remaining processes"
-       killall5 -9 $OMITPIDS # SIGKILL
-       log_action_end_msg 0
+       if [ -z "$alldead" ] ; then
+           log_action_begin_msg "Killing all remaining processes"
+           killall5 -9 $OMITPIDS # SIGKILL
+           log_action_end_msg 0
+       fi

 splash_back() {

Happy hacking,
Petter Reinholdtsen

Reply to: