httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mikhail T." <>
Subject Re: reopening of logs without restarting
Date Fri, 22 Jan 2010 20:11:27 GMT
22.01.2010 14:50, Brian J. France написав(ла):
> Funny you should bring this up, at work we have been look at out patches to apr and httpd
that we can give back to the up stream public source and one of those patches is to apr to
allow hupless log rotation in httpd 2.x.
> The patch adds APR_FOPEN_ROTATING to the flags when opening a file (which we patch httpd
to add it), then open will save extra data after opening (flags, perm, apr_finfo_t, last check
and timeout).  If APR_FOPEN_ROTATING is set then before every write call it will check to
see if it needs to re-stat the file to see if anything has change (device/inode) and if it
has it will re-open the file automatically.
> This allows us to move log files to a new name, wait X seconds (our default timeout is
60, so we wait 90 to be safe) and then we can do what ever we want to the log file because
all children will have either re-opened it or will re-opened it before the next write call.
> Is that what you are looking for?
> I was going to bring up the patch during the Monday/Tuesday hack days along with a few
It is very close, thank you very much. If you publish it, I will be able 
to improve it to my taste -- instead of stat-ing every time (a 
potentially expensive thing to do), it would only perform the reopening 
upon receiving a signal (such as SIGUSR2).

With that you'll have to rename the current files, send all 
httpd-processes the signal and wait for the new files to appear before 
compressing the renamed ones, etc.

BTW, if you are on Irix, Linux, Solaris-10, or a BSD system, you can 
improve your work yourself to avoid that 90 second wait too. The OSes I 
listed all have mechanisms, whereby a program can ask the kernel to 
notify it of certain events (such as new files appearing in a given 
directory). Unfortunately, the mechanisms are quite different on all 
OSes (dnotify on Linux, kqueue on BSD, etc.), but you only need to 
implemented it for /yours/ :-)

And finally, should not a module be able to perform all the reopening on 
its own -- without patching the server code? Or the modules don't have 
access to all the necessary functions/values?

Thanks! Yours,


View raw message