[Twisted-Python] log rotation

Hi Has anyone used logrotate or simple use a cron job to send a SIGUSR1 to the process? If I understand the twistd man page properly, the log file will be rotated on SIGUSR1, therefore I'm wont be able to use logrotate to do the rotation? Thanks -Liming

On Tue, 21 Sep 2004 11:14:38 +0800, Tsai Li Ming <mailinglist@ltsai.com> wrote:
logrotate should rotate twistd logfiles just fine. It shuts down a process, moves its log files around, then restarts it. Why you'd _want_ to rotate them this way, instead of just letting them automatically be rotated by twistd (which they will be), I dunno. Is there some feature logrotate has that twistd lacks that you're interested in? Jp

On Sep 21, 2004, at 9:21 AM, <exarkun@divmod.com> wrote:
logrotate should rotate twistd logfiles just fine. It shuts down a process, moves its log files around, then restarts it.
That's not how it normally works. Generally one of two strategies is employed: - Move the current log files, then send a signal to the process to tell it to reload its configuration file, which causes it to reopen the logfiles. - Copy the log files, and truncate the old file. The first option is much nicer, so ideally for integration with logrotate, you would want to install some signal-handler that tells twistd to reopen all its logfiles. James

James Y Knight wrote:
Hi James, That's what I would thought too. 1. logrotate will rotate the file. (server -> server.1) 2. a signal (usually a HUP) is sent to the process and the process will close the log file's FD. (server.1) 3. Process will reload it's current configuration and write to a new log file. (server) However, Twisted has its own mechanism of handling log rotation. Liming

On Tue, 21 Sep 2004 11:14:38 +0800, Tsai Li Ming <mailinglist@ltsai.com> wrote:
logrotate should rotate twistd logfiles just fine. It shuts down a process, moves its log files around, then restarts it. Why you'd _want_ to rotate them this way, instead of just letting them automatically be rotated by twistd (which they will be), I dunno. Is there some feature logrotate has that twistd lacks that you're interested in? Jp

On Sep 21, 2004, at 9:21 AM, <exarkun@divmod.com> wrote:
logrotate should rotate twistd logfiles just fine. It shuts down a process, moves its log files around, then restarts it.
That's not how it normally works. Generally one of two strategies is employed: - Move the current log files, then send a signal to the process to tell it to reload its configuration file, which causes it to reopen the logfiles. - Copy the log files, and truncate the old file. The first option is much nicer, so ideally for integration with logrotate, you would want to install some signal-handler that tells twistd to reopen all its logfiles. James

James Y Knight wrote:
Hi James, That's what I would thought too. 1. logrotate will rotate the file. (server -> server.1) 2. a signal (usually a HUP) is sent to the process and the process will close the log file's FD. (server.1) 3. Process will reload it's current configuration and write to a new log file. (server) However, Twisted has its own mechanism of handling log rotation. Liming
participants (4)
-
exarkun@divmod.com
-
James Y Knight
-
Jonathan Simms
-
Tsai Li Ming