Re: Question about shutdown

From: as web server manager <webadm@dont-contact.us>
Date: Tue, 13 Oct 1998 21:33:24 +0100 (BST)

Jens Elkner wrote:
>
> 'Duane Wessels wrote:'
> > squid@sminter.com.ar writes:
> >
> > >Hello:
> > > When I kill squid I see a lot of lines in cache.log looking like
> > >"xxxx lines written".
> > > The thing is, when I halt the server, it shuts down inmediatedly.
> > >Is this safe?
> > > I am asking this because I want to prepare my UPS-started shutdown
> > >script.
> >
> > Its "safe" but not optimal.
> >
> > If squid exits without writing the clean log, it will be a little
> > bit slower the next time it starts up. Also that increases the chance
>
> ...
>
> Well, on our 24 GB parent startup takes about 3 hours when the swaplog
> is broken (i.e. squid was not shutdowned properly). So ...

In my startup/shutdown script, it sends TERM signals to RunCache (so it
won't try restarting Squid as soon as it stops, if it gets the chance) and
to squid, and then does

    count=90 # timeout in seconds
    while [ "$count" -gt 0 ]
    do
        kill -0 $spid 2> /dev/null
        if [ $? -ne 0 ]
        then
            echo "Squid (from ${sdir}) shutdown complete."
            break
        fi
        if [ `expr $count % 10` -eq 0 ]
        then
            echo "Waiting up to $count seconds for Squid (from ${sdir}) to termnate."
        fi
        sleep 1
        count=`expr $count - 1`
    done
    if [ "$count" -le 0 ]
    then
        echo "Gave up waiting for Squid to terminate."
    fi

[This assumes you don't have other slow things to do in parallel with Squid
terminating; you could do other things then wait a while if some still
haven't finished. The time limit ensures it shouldn't just hang - inevitably
when you're not on-site to fix it - because something refuses to shut down.]

The 90 seconds will be approximate (since sleep is approximate), but with
our cache it's currently adequate and for controlled shutdowns (as opposed
to power failure or system crash...) it normally avoids Squid having to
spend hours scanning the cache to rebuild the file.

The commonest cause of it having to rebuild the file has been me forgetting
that it takes several minutes to reload the file on startup (though it can
handle requests before that), and if you stop it again before it has
finished, it *will* have to rebuild the file when next started. [With
1.NOVM.20-era Squid versions, at least, haven't looked seriously at 2.0
yet.]

                                John Line

-- 
University of Cambridge WWW manager account (usually John Line)
Send general WWW-related enquiries to webmaster@ucs.cam.ac.uk
Received on Tue Oct 13 1998 - 14:20:20 MDT

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:42:29 MST