On Thu, 2009-11-26 at 14:28 +0200, Janne Karhunen wrote:

> Finally got around to this. There's a hacky patch attached that
> introduces 'reboot' stanza that will issue reboot given that we
> hit respawn limit for 'reboot' marked task. While this seems
> working, issuing reboot is probably not the correct way to
> reboot. Scott, your comments?
> 
The "stopped" event has special arguments when Upstart stops a job due
to failed respawn, as described in stopped(7):

       When  the  job  has failed, the process that failed
       will be given in the PROCESS environment  variable.
       This  may  be pre-start, post-start, main, pre-stop
       or post-stop; it may  also  be  the  special  value
       respawn  to  indicate  that  the  job  was  stopped
       because it hit the respawn limit.

This means that you could just do (as a file in /etc/init):

        start on stopped $JOB RESULT=failed PROCESS=respawn
        exec /sbin/reboot

You can make that more generic if you like, a job that should cause a
reboot when respawn fails could have (in its config file):

        env REBOOT_ON_RESPAWN_FAIL=1
        export REBOOT_ON_RESPAWN_FAIL

Then your reboot job could match it with:

        start on stopped REBOOT_ON_RESPAWN_FAIL=1 \
                RESULT=failed PROCESS=respawn
        exec /sbin/reboot


I'm not totally convinced that reboot-on-respawn-fail is a sufficiently
common use case to have a built in especially for it, especially since
you can get the behaviour you want already :-)

Scott
-- 
Have you ever, ever felt like this?
Had strange things happen?  Are you going round the twist?

Attachment: signature.asc
Description: This is a digitally signed message part

-- 
upstart-devel mailing list
[email protected]
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/upstart-devel

Reply via email to