0

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

respawn
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?

1 Answers1

0

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:

respawn
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.

sam_pan_mariusz
  • 2,133
  • 1
  • 14
  • 15