problem with start on started / stop on stopped

Marcel Kinard marcelk at us.ibm.com
Wed Mar 10 03:00:46 GMT 2010


Here's a scenario: I have two processes - an application and a watchdog. 
The watchdog exercises the application (instead of just checking its 
presence). If the watchdog sees that the application health is poor, I 
want the application to be restarted. 

So inside the watchdog when it sees bad health it will run "initctl emit 
application-unhealthy" and stop exercising. But when the application is 
stopped, I also want the watchdog to be stopped, so that the watchdog gets 
restarted in a clean state after the application gets started, and the 
watchdog doesn't try to exercise the application that isn't there. So here 
are the config files I put in /etc/init:

application.conf:
        start on startup or application-kickstart
        stop on application-unhealthy
        exec /home/marcelk/application
        respawn

watchdog.conf:
        start on started application
        stop on stopping application
        exec /home/marcelk/watchdog
        respawn

On boot both the application and watchdog start. If I "initctl emit 
application-unhealthy" then only the application stops, not the watchdog. 

I did a "initctl log-level debug" before the "initctl emit 
application-unhealthy" and it says it is completing the stopping and 
stopped events for application, but there is no reference to watchdog. Am 
I correct to understand that this should work as I expect?

Another option would be for the watchdog to explicitly invoke "initctl 
restart application" and for the watchdog itself to stay up during the 
application restart. Would that initctl invocation block until the 
application was stopped and restarted?

What would be nice is a "restart on ..." stanza. I could also see that an 
"restart limit ..." stanza should follow.

Given the way that upstart was designed, any other models I should look at 
for an elegant application/watchdog functionality? Thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://lists.ubuntu.com/archives/upstart-devel/attachments/20100309/3e60b659/attachment.htm 


More information about the upstart-devel mailing list