[Spread-users] Re: Log rotation

Theo E. Schlossnagle jesus at omniti.com
Wed Dec 18 10:32:12 EST 2002

Guido van Rossum wrote:
> I wrote:
>>Quick question: we need to rotate our logfiles without killing and
>>restarting the spread daemon.  Can this be done?
> I already received one answer that doesn't help me.  I'm not asking
> how to rotate logs.  I'm asking whether, when the logfile is moved,
> the spread daemon will keep logging to the renamed file or whether it
> will detect this situation and start logging to the new logfile (with
> the original name).  IOW does it keep the file descriptor open or not?

It opens it once and continuously writes to it.  So no, you can't rotate them. 
  Ideally, we would send Spread a SIGHUP and it would close and reopen the log 
file.  On som systems opening a logfile in append mode for every write is uber 
painful. The alternative -- stat'ing the file and checking its inode/device 
numbers for a match and close/reopen on mismatch is a good approach, but it 
causes a stat call for every log line, which is relatively cheap, but 
unnecessary overheadh IMHO.

Ideally, since spread isn't multithreaded we would set up something like:

Add an alarm.c function:
void alarm_reopen_on_next_write();
which will set a flag that will cause the next write to close the log, reopen 
the log and reset that flag.

Then we just add a signal handler that calls that function.  This is the way 
spreadlogd works (as well as most other apps) and it works like a charm.

However, all of the other system calls need to be used in a signal-safe 
manner.  I _think_ that they are already, which would make this modification 

Theo Schlossnagle
Principal Consultant
OmniTI Computer Consulting, Inc. -- http://www.omniti.com/
Phone:  +1 410 872 4910 x201     Fax:  +1 410 872 4911
1024D/82844984/95FD 30F1 489E 4613 F22E  491A 7E88 364C 8284 4984
2047R/33131B65/71 F7 95 64 49 76 5D BA  3D 90 B9 9F BE 27 24 E7

More information about the Spread-users mailing list