Rotating server logs?

48 views
Skip to first unread message

mage2k

unread,
Oct 14, 2009, 1:41:11 PM10/14/09
to mongodb-user
Is there any way to have a running server close and re-open it's log
file? Sending the server a SIGHUP signal seems to kill it outright.
On that last poing, should I open a bug report? A SIGHUP really
shouldn't be killing a server...

Eliot Horowitz

unread,
Oct 14, 2009, 2:33:17 PM10/14/09
to mongod...@googlegroups.com
Are you using --logpath?
There isn't a way to do log rotation, but we could add.

You should add cases for sighup and log rotation.

mage2k

unread,
Oct 14, 2009, 2:47:31 PM10/14/09
to mongodb-user
Thanks, will do.

mage2k

unread,
Oct 14, 2009, 4:49:02 PM10/14/09
to mongodb-user
Ok, case opened for log rotation. I didn't, however, open a separate
case for SIGHUP signal handling since the default action for a process
is exit, which is what it does now, although I did suggest using it to
have the server re-open it's log in the log rotation case.

Jon Hancock

unread,
Oct 15, 2009, 2:37:42 PM10/15/09
to mongodb-user
I'm not sure what SIGHUP should do. But if your going to have SIGHUP
help with log files per this requirement, then SIGHUP should probably
be doing things like re-reading config files as well.

Jon

Eliot Horowitz

unread,
Oct 15, 2009, 3:27:06 PM10/15/09
to mongod...@googlegroups.com
What do you guys think about USR1 for rotating logs?
I'm a bti reluctant to use HUP

timball

unread,
Oct 15, 2009, 4:58:19 PM10/15/09
to mongodb-user
i would say that USR1 would be the better signal to use. stays inline
w/ the nginx[0] way to do it. SIGHUP is used by apache[1] as a rather
large kludge, just remember that you'll need a global static volatile
sig_atomic_t somewhere to set the signal mask back[2] when coming back
from a function.

i can't believe you guys don't trap most usergenerated signals like
Richard W. Stevens says too!

but either way it would be *very* nice to be able to rotate a log. if
i get done making dinner early enough i might send in a patch tonight.

--timball

[0] http://www.ruby-forum.com/topic/134115
[1] http://httpd.apache.org/docs/2.2/stopping.html
[2] so says RWS in APUE 10.15

On Oct 15, 3:27 pm, Eliot Horowitz <eliothorow...@gmail.com> wrote:
> What do you guys think about USR1 for rotating logs?
> I'm a bti reluctant to use HUP
>
Reply all
Reply to author
Forward
0 new messages