httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Brian J. France" <>
Subject Re: reopening of logs without restarting
Date Fri, 22 Jan 2010 19:50:53 GMT
On Jan 22, 2010, at 1:43 PM, Mikhail T. wrote:
> Hello!
> Some of our web-servers take a while to restart (because some custom
> modules need to login to database backends, etc.) This makes it
> undesirable for us to use the SIGUSR1 (for graceful restart) and we
> currently log to stdin of an easier to restart command-line utility.
> How hard would it be to implement a separate signal-handler, which
> would -- upon receiving, say, SIGUSR2 -- reopen the log-files without
> performing a full restart of each worker? That would provide for a
> possibility to log straight into a file and rotate that once in a while
> without a full restart of the httpds.
> Currently there are ap_run_open_logs and worker_open_logs. Can my
> hypothetical signal-handler simply go through the list of opened
> descriptors, set them to new values and close the old?
> Or is this a "hairy" task, that some have tried, but nobody succeeded
> in implementing?

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 others.


View raw message