reacting to respawn giving up?
Scott James Remnant
scott at netsplit.com
Tue Dec 1 18:14:57 GMT 2009
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?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part
Url : https://lists.ubuntu.com/archives/upstart-devel/attachments/20091201/1c44c9cf/attachment.pgp
More information about the upstart-devel
mailing list