librelist archives

« back to archive

Re: [mongrel2] Log file rotation ?

Re: [mongrel2] Log file rotation ?

From:
Nathan Duran
Date:
2011-07-01 @ 05:14
> Would there be any interest from others in getting a rotate command added into
> m2sh ?

Can you not use logrotate? I don't see any reason for Mongrel2 to duplicate
its functionality, personally.

Re: [mongrel2] Log file rotation ?

From:
Dave Dodd
Date:
2011-07-01 @ 06:02
On Thu, Jun 30, 2011 at 10:14:18PM -0700, Nathan Duran wrote:
> > Would there be any interest from others in getting a rotate command added into
> > m2sh ?
> 
> Can you not use logrotate? I don't see any reason for Mongrel2 to duplicate
> its functionality, personally.
> 

I can use newsyslog given I am in a FreeBSD environment and have root access.

What I cannot do is know that the server will close & reopen the logs on
receipt of the SIGHUP from whatever log rotation tool I use.

To hopefully clarify the problem, the reload operation does not close and
reopen the log files, so the server will continue to write to the original log
files until it is stopped and restarted.  The reload command _should_ close
and reopen the log files.

Given the reload command is also delayed until the next request, you cannot
actully guarantee _when_ the reload will occur short of prodding it yourself.

So ... I think a rotate command is in order and furthermore a hook to call a
user defined rotation script should be provided as well.

-- Dave

Re: [mongrel2] Log file rotation ?

From:
Isaac Force
Date:
2011-07-01 @ 06:33
On Thu, Jun 30, 2011 at 11:02 PM, Dave Dodd <dave@ci.com.au> wrote:
> What I cannot do is know that the server will close & reopen the logs on
> receipt of the SIGHUP from whatever log rotation tool I use.
>
> So ... I think a rotate command is in order and furthermore a hook to call a
> user defined rotation script should be provided as well.

Wouldn't a signal to reload log files be sufficient? mv the logs to
new names (M2 should continue appending to the open inodes), send
SIGFOO, and the logger refreshes and creates new files as necessary.

-Isaac

Re: [mongrel2] Log file rotation ?

From:
Dave Dodd
Date:
2011-07-01 @ 06:52
On Thu, Jun 30, 2011 at 11:33:14PM -0700, Isaac Force wrote:
> On Thu, Jun 30, 2011 at 11:02 PM, Dave Dodd <dave@ci.com.au> wrote:
> > What I cannot do is know that the server will close & reopen the logs on
> > receipt of the SIGHUP from whatever log rotation tool I use.
> >
> > So ... I think a rotate command is in order and furthermore a hook to call a
> > user defined rotation script should be provided as well.
> 
> Wouldn't a signal to reload log files be sufficient? mv the logs to
> new names (M2 should continue appending to the open inodes), send
> SIGFOO, and the logger refreshes and creates new files as necessary.
> 
> -Isaac

For my specific case, yes, a signal will be quite sufficient.

I figured that an optional hook for a user script to do the rotation would
give more flexibility in the myriad ways mongrel2 can be deployed.

-- Dave

Re: [mongrel2] Log file rotation ?

From:
Zed A. Shaw
Date:
2011-07-01 @ 22:03
On Fri, Jul 01, 2011 at 04:52:15PM +1000, Dave Dodd wrote:
> For my specific case, yes, a signal will be quite sufficient.
> 
> I figured that an optional hook for a user script to do the rotation would
> give more flexibility in the myriad ways mongrel2 can be deployed.

I can add that, can you make a ticket for it in the github tickets?

-- 
Zed A. Shaw
http://zedshaw.com/

Re: [mongrel2] Log file rotation ?

From:
Dave Dodd
Date:
2011-07-02 @ 04:02
On Fri, Jul 01, 2011 at 03:03:03PM -0700, Zed A. Shaw wrote:
> On Fri, Jul 01, 2011 at 04:52:15PM +1000, Dave Dodd wrote:
> > For my specific case, yes, a signal will be quite sufficient.
> > 
> > I figured that an optional hook for a user script to do the rotation would
> > give more flexibility in the myriad ways mongrel2 can be deployed.
> 
> I can add that, can you make a ticket for it in the github tickets?
> 
> -- 
> Zed A. Shaw
> http://zedshaw.com/

Issue #62 opened.

-- 
David Dodd
Corinthian Engineering Pty Limited
Suite 54, Jones Bay Wharf
26-32 Pirrama Road
Pyrmont NSW 2009 Australia
Telephone +612 9552 5500 Fax +612 9552 5549

Re: [mongrel2] Log file rotation ?

From:
Matt Towers
Date:
2011-07-01 @ 14:55
Logroate should do what you want.  Check out the 'copytruncate' option.

 copytruncate
              Truncate  the  original log file in place after creating a copy,
              instead of moving the old log file and optionally creating a new
              one,  It  can be used when some program can not be told to close
              its logfile and thus might continue writing (appending)  to  the
              previous log file forever.  Note that there is a very small time
              slice between copying the file and truncating it, so  some  log-
              ging  data  might be lost.  When this option is used, the create
              option will have no effect, as the old log file stays in  place.

✈ Matt



On Jun 30, 2011, at 23:52 , Dave Dodd wrote:

> On Thu, Jun 30, 2011 at 11:33:14PM -0700, Isaac Force wrote:
>> On Thu, Jun 30, 2011 at 11:02 PM, Dave Dodd <dave@ci.com.au> wrote:
>>> What I cannot do is know that the server will close & reopen the logs on
>>> receipt of the SIGHUP from whatever log rotation tool I use.
>>> 
>>> So ... I think a rotate command is in order and furthermore a hook to call a
>>> user defined rotation script should be provided as well.
>> 
>> Wouldn't a signal to reload log files be sufficient? mv the logs to
>> new names (M2 should continue appending to the open inodes), send
>> SIGFOO, and the logger refreshes and creates new files as necessary.
>> 
>> -Isaac
> 
> For my specific case, yes, a signal will be quite sufficient.
> 
> I figured that an optional hook for a user script to do the rotation would
> give more flexibility in the myriad ways mongrel2 can be deployed.
> 
> -- Dave