We thought the following directives would try to respawn the process 10 times in 60 seconds (i.e. once every 6 seconds):

respawn limit 10 60

However these directives restart the process as soon as it is crashed. So it might actually respawn the process 10 times in 1 second.

Is there a way to configure our service so that when it crashes, it tries ti respawn it 10 times, once every 6 seconds?


Ubuntu Upstart Cookbook has an answer for this:

If a job specifies respawn, but you want to delay the respawn for some reason, simply use a post-stop stanza:

exec mydaemon
post-stop exec sleep 10

Now, every time mydaemon exits with a non-zero return code, the job will sleep for 10 seconds before Upstart restarts it.

For a real service, you would probably use a post-stop script stanza to perform a check rather than simply sleeping.

To be honest, I'm not sure if and why post-stop is called only on non-zero job exit codes, but this is the solution the manual suggests. You can always use post-start script and add a check to make sleep ... conditional.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.