[sheepdog-users] logrotate

Hitoshi Mitake mitake.hitoshi at lab.ntt.co.jp
Tue Oct 14 08:42:31 CEST 2014


Hi Valerio, Marcin,

Thanks for checking the behavior. It seems that there is a workaround
for debian's logrotate utility. Can I close the issue:
https://bugs.launchpad.net/sheepdog-project/+bug/1371434
?

Currently I don't know why other daemon processes on debian can adopt
debian's logrotate (for me, there's no event for detecting rename of
logfile). It should be solved in the future. But let's use the
workaround for now.

Thanks,
Hitoshi

At Sat, 11 Oct 2014 14:03:06 +0200,
Marcin Mirosław wrote:
> 
> W dniu 2014-10-11 o 12:36, Valerio Pachera pisze:
> 
> Hi!
> 
> > A Yuan suggests, kill -HUP is going to rotate the log.
> > 
> >> lib/log.c, the handler for SIGHUP is
> >> rotate_log() /* line 557 */
> > 
> > I've been testing this and I have some notes and consideration:
> > 
> > 1) it's enough to send the signal to one of the two sheep processes.
> >      Using killall is going to empty the rotated log.
> 
> Meseems there is only one sheep process all remains occurence of sheep
> are only threads. HUP should be send only to the main process (as you
> observed). Using killall isn't good, I'm going explain it later in email.
> 
> > 2) rotate_log() uses a suffix when rotating logs, e.g.
> > sheep.log.2014-10-11-11-42
> > 3) The function rotate_log() duplicates what the utility 'logrotate' does.
> 
> Imho sheep.log shouldn't bother rotating logs, sheep should have feature
> to reopen new log file (e.g. after receiving HUP). Rotating logs are
> task for other utility (logrotate).
> 
> > Both of the following basic configurations are working fine.
> > I don't understand why, the first doesn't create logs with the date
> > suffix as when sending manually kill -HUP.
> > Because of this, I feel more confident with the second.
> > 
> > /mnt/sheep/0/sheep.log {
> >         rotate 4
> >         notifempty
> >         postrotate
> >                 /bin/kill -HUP $(pgrep sheep | head -1)
> >         endscript
> > }
> 
> Sending HUP to random process of sheep isn't good:
> - pgrep doesn't guarantee that pid of main thread (process) will be
> displayed first
> - what if we have more than one sheep started on the same host? You are
> going to rotate one log and send HUP to one (which one? Is given process
> associated with rotated log?)
> 
> Imho init script should send HUP to pid of process started by this init
> script. We can more than one intance of sheep (and init script) all of
> them should be separately configured in logrotate (because different
> sheeps logs to different files).
> I think that such generic configuration should be enough to work:
> /path/to/sheep0/log/sheep.log {
>       notifempty
>       postrotate
> 		</path/to/init/script> rotate # in this place we are calling init
> script to send e.g. HUP to proper, one process of sheep.
>       endscript
> }
> 
> You mentioned that HUP calls rotate_log() in sheep and sheep changes
> name of log file. IMHO after HUP sheep should close old log file and
> open new, and nothing more (as I said it earlier). Changing name,
> compressing and other foo things should be done by logrotate.
> Unfortunatelly I don't have time now to setup test enviroment and check
> how much my theory are far from real behavior of sheep:).
> Regards,
> Marcin
> 
> 
> -- 
> sheepdog-users mailing lists
> sheepdog-users at lists.wpkg.org
> http://lists.wpkg.org/mailman/listinfo/sheepdog-users



More information about the sheepdog-users mailing list