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

Re: logrotate.d/apache restart method



Lauren Matheson said:
> Hello,
> 
> Apache's logrotate entry includes:
> 
>         postrotate
>                 /etc/init.d/apache reload > /dev/null
>         endscript
> 
> would it be worthwhile to change this to:
> 
>         postrotate
>                 /usr/sbin/apachectl graceful > /dev/null
>         endscript
> 
> Currently, if the apache config files are broken for whatever reason,
> the server will stop when logrotate runs.  Granted the config files
> should not be broken, but better still to let the running server run.
> 
> Open for feedback,
> Lauren.

Maybe, but I'm not convinced.  Fundamentally they're the same thing:
'apachectl graceful' and 'apache reload' both send a USR1 signal to the
running Apache process.  It is an assumption of the init.d script that
if it's being called to reload Apache, that apache is already running
and its config files are unbroken.  The functionality of the 'apachectl
graceful' should arguably be added to /etc/init.d/apache, perhaps as a
'logrotate' case.  It is however outside the bounds of an init.d
script's 'reload' clause to start the daemon if it is not already
running, IIRC.  That's probably described in Debian Policy somewhere.

You can of course modify the logrotate conf on your own systems as you
see fit.  =)

Also, consider this: if Apache had its logfiles rotated but then it was
not restarted because the config was broken, then conceivably this could
happen again at the next rotation, and those logfiles still being written
to by Apache will be compressed (log -> log.0 -> log.1.gz).  After the
compress is finished, gzip would unlink the log file, but it would not
be removed from the disk because Apache still has it open and is writing
to it.  On a busy server with rapidly growing log files, you could then
find you've run out of disk because of a log file that is open but does
not appear with 'ls' because it has been unlinked from the directory.

Alternatively, if Apache dies immediately after your log files are
rotated, you will find out very quickly, and you will fix it.  =)

This isn't necessarily the rationale for why things are the way they
are, but it is (hopefully) an accurate look at the wider picture.

Andrew.

-- 
Andrew Shugg <andrew@neep.com.au>                   http://www.neep.com.au/

"Just remember, Mr Fawlty, there's always someone worse off than yourself."
"Is there?  Well I'd like to meet him.  I could do with a good laugh."



Reply to: