Discussion:
[Supervisor-users] Can supervisor restart conditionally based on process age?
Matthew Wilson
2009-02-22 17:37:38 UTC
Permalink
This is a funky problem, and vaguely off-topic.

My webapp writes to five different log files in a directory. I use
logrotate to rotate the log files daily and then restart my web app.
The logrotate config looks sort of like:

/var/log/turbogears/*.log {

# Rotate the logs every day.
daily


# Now tell supervisord to restart all these scripts, so that they
# don't keep logging to the old files.
postrotate
supervisorctl restart webapp
endscript

}

Here's the problem: since I have five log files to rotate, logrotate
restarts my app five times!

Is there some cool way to tell supervisor that it should only restart
my webapp if the process is more than, say, one hour old? Then the
needless restarts would get ignored.

There's probably a solution to this that involves writing a better
logrotate config, but I haven't figured that out either.

All comments welcome! supervisor is great software.

Matt
--
Matthew Wilson
***@tplus1.com
http://tplus1.com
Quest
2009-02-23 21:45:33 UTC
Permalink
Post by Matthew Wilson
This is a funky problem, and vaguely off-topic.
My webapp writes to five different log files in a directory. I use
logrotate to rotate the log files daily and then restart my web app.
/var/log/turbogears/*.log {
# Rotate the logs every day.
daily
# Now tell supervisord to restart all these scripts, so that they
# don't keep logging to the old files.
postrotate
supervisorctl restart webapp
endscript
}
Here's the problem: since I have five log files to rotate, logrotate
restarts my app five times!
Is there some cool way to tell supervisor that it should only restart
my webapp if the process is more than, say, one hour old? Then the
needless restarts would get ignored.
There's probably a solution to this that involves writing a better
logrotate config, but I haven't figured that out either.
All comments welcome! supervisor is great software.
logrotate sharedscripts?
--
"How can I tell that the road signed to hell - doesn't lead up to heaven?"
-- Peter Hammill; The Comet, The Course, The Tail
Matthew Wilson
2009-02-23 22:32:57 UTC
Permalink
Post by Quest
logrotate sharedscripts?
Wow, that is exactly what I needed. Thanks!
--
Matthew Wilson
***@tplus1.com
http://tplus1.com
Loading...