DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUGĀ·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=44427>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED ANDĀ·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=44427

           Summary: Externally triggered rotatlogs rotation
           Product: Apache httpd-2
           Version: 2.3-HEAD
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: PatchAvailable
          Severity: enhancement
          Priority: P2
         Component: support
        AssignedTo: [email protected]
        ReportedBy: [EMAIL PROTECTED]


There is a common problem of how to compress/archive log files without
restarting the server processes.

Although rotatelogs solves the problem partially by rotating size or time based,
there remains the problem of files to which data is written not often enough,
like error logs. Rotatelogs only checks the rotation conditions, when it has
something to write to the files.

People placing their log files on NFS and running compress cron jobs end up with
a lot of .nfs files, because the compression removes the original files, which
are still open by rotatelogs waiting (maybe since a long time) for some message
to handle.

The solution to (gracefully) restart Apache has the disadvantage, that it
destroys status information. Altough the info in the status handler is maybe not
that important to accumulate for a long time, there is the example of mod_jk
that allows dynamic but non-persistant changes in the configuration, thus
allowing people to temporarily disable workers. Often people do thet in the
evening to prepare for updates on the next day and automatic restart scripts for
the web servers will undo those changes :(

Another solution is to allow rotatlogs to wake up by an external trigger and
then close the open file if the rotation conditions are fulfilled.

I rearranged the 2.2 rotatelogs and included a signal handler for SIGHUP, which
closes the file if size or tim conditions are met. The doesn't get immediately
opened, because it might be, that there is no need for the new file for more
than the next rotation interval.

The code seems to work fine, but maybe could be improved. I don't attach a
patch, because I moved bigger code parts into functions and thus the patch is
not really helpful. When looking at it logically, the changes mostky are:

- Move condition checks into a function
- Move Close and open into a function
- Put the config variables into a struct in order to pass them more easily
between main and functions
- The same for the dynamic status variables
- Register signal handler for SIGHUP that calls the rotation check and closes
the old file if necessary
- unblock signal only during the apr_read_file() call

I've got no idea, what needs to get changed for Windows.

The signal handling relies on the implementation detail of apr_file_read(), that
it catches any interruption in the inner read in a loop.

If there is some interest in such a solution, I would also provide 2.3 and 2.2
head based code versions.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to