On Wed, Jul 02, 2003 at 03:50:15PM +0300, Jim Xochellis wrote:

[ Dealing with processes that keep an open file descriptor on their
log files, and that don't understand the use of SIGHUP to reopen the
file]

> 1) Many servers (netatalk, samba, apache, etc) are creating many 
> processes which are all using the same log files. Hence, these servers 
> have already solved the above problems somehow.

I know very little about netatalk, but of the other two packages you
mention:

    apache understands the HUP signal and will do a restart, including
    reopening its log files as desired.  Even better, it understands
    the USR1 signal (signal 30) as a "graceful restart" -- that means
    that apache child processes that are actually serving out a
    request at the time of the signal will be permitted to finish
    before closing down.

    See: http://httpd.apache.org/docs/stopping.html

    You can use a line like this in /etc/newsyslog.conf to cycle the
    httpd-access.log.  You'll need similar lines for httpd-error.log,
    ssl_engine_log, ssl_request_log or any other log file your httpd
    generates.

    /var/log/httpd-access.log 644 20 100 * Z /var/run/httpd.pid 30

    samba can also generate a lot of log files depending on
    configuration.  However, it also can be configured to put out all
    of it's logging information via syslog(3).  Samba is also capable
    of recycling it's own log files.  See the 'max log size' entry in
    smb.conf:

    http://samba.mirror.ac.uk/samba/docs/man/smb.conf.5.html#MAXLOGSIZE

> 2) When implementing logging we are always flushing the log file *very* 
> frequently and I believe that this fact is reducing the possibility of 
> facing the above problems.

Yes -- a well behaved process will certainly not assume that it is the
only process that can write to any particular file.  The worse
programs in this respect are those where the log output is simply the
result of redirecting the stdout/stderr of the program.  Jakarta
Tomcat is pretty bad in that respect.

> 3) I have done some tests my self and had no problems at all. (Of 
> course that is not a proof, just an indication...)

[...]
 
> I am thinking about changing the newsyslog instead (adding an option) 
> but I am such a newbie in Unix, makefiles and all this stuff (except c) 

Go for it.  The ideal would probably be to add another flag to the
'flags' column to go with the BCGJNUWZ- flags it already understands,
so that you can apply the 'file descriptor friendly' method of
updating on a per-file basis.  Unless you're going to be adding whole
new files to the newsyslog sources, then you shouldn't need to modify
any Makefiles at all.

Once you're happy with your modifications, you can submit them back to
the project for review and maybe eventual adoption by using send-pr.
Don't forget to update the man page as well.

        Cheers,

        Matthew

-- 
Dr Matthew J Seaman MA, D.Phil.                       26 The Paddocks
                                                      Savill Way
PGP: http://www.infracaninophile.co.uk/pgpkey         Marlow
Tel: +44 1628 476614                                  Bucks., SL7 1TH UK

Attachment: pgp00000.pgp
Description: PGP signature

Reply via email to