[CRIU] [PATCH] service: rotate log by SIGHUP

Pavel Emelyanov xemul at parallels.com
Tue Feb 11 00:29:28 PST 2014


On 02/11/2014 12:17 PM, Ruslan Kuprieiev wrote:
> On 11.02.2014 12:11, Vladimir Davydov wrote:
>> On 02/11/2014 11:49 AM, Ruslan Kuprieiev wrote:
>>> On 11.02.2014 11:28, Vladimir Davydov wrote:
>>>> On 02/11/2014 11:11 AM, Ruslan Kuprieiev wrote:
>>>>> Because we wan't service to work non-stop.
>>>>> And, as far as I know, by just using logrotate we will need to restart
>>>>> service.
>>>> Not necessarily, you can specify what should be done after rotate
>>>> (`postrotate'), e.g. send a signal to your service so that it could
>>>> reopen the logfile. However, I guess that `copytruncate' would be enough
>>>> in your case.
>>> But what if service will write something between the moment when
>>> logrotate will copy log and the moment when it will send signal to
>>> service?
>> Oh, if your logs are so valuable that loosing a message or two once a
>> day/week/month is a disaster, then logrotate is, of course, not an
>> option for you, sorry.
> =)
>> However, from what I see you have the same race in your implementation:
>> what if somebody prints to log while you're renaming it (after
>> log_fini(), but before log_init())? Errors will go to stderr, which
>> should be closed for a daemon?
> 
> In theory, no one, except service daemon, can write to that log.(In 
> theory, because we are not shutting down log for children, but it needs 
> to be done soon).
> And as it rotate log in signal handler, service can't write to log, 
> while signal handler is working.

That's OK. Child gets log_fd from parent and keeps writing in it
regardless of what's done with the log file by logrotate daemon.


More information about the CRIU mailing list