understanding respawn limit

Asked by Sandeep

Hi,
I am running upstart 0.5 and have a question about the respawn option.
I have started init with the debug option.

My job file looks like this
***/etc/init/jobs.d/job2***
start on emit_job2
respawn limit 4 500
exec bin/sleep 200

From the console, I do the following
initctl emit emit_job2
I then get the pid of job2 (sleep) and kill it. I expect it to be respawned but it does not.

I am trying to understand how the respawn limit should work. From the front page, the documentation says
"The respawn limits function as follows: If the process is respawned more than count times within an interval of timeout seconds, the process will be stopped automatically, and not restarted. Unless set explicitly, the limit defaults to 10 times within 5 seconds. "

Here is what i see in the /var/log/messages
Aug 23 10:01:28 10 <1219485688,743544>init: Connection from private client
Aug 23 10:01:30 10 <1219485690,550660>init: Handling emit_job2 event
Aug 23 10:01:33 10 <1219485690,556292>init: job2 goal changed from stop to start
Aug 23 10:01:33 10 <1219485690,556928>init: job2 state changed from waiting to starting
Aug 23 10:01:33 10 <1219485690,558956>init: Handling starting event
Aug 23 10:01:34 10 <1219485690,560232>init: job2 state changed from starting to pre-start
Aug 23 10:01:34 10 <1219485690,560836>init: job2 state changed from pre-start to spawned
Aug 23 10:01:35 10 <1219485695,104116>init: job2 main process (2163)
Aug 23 10:01:35 10 <1219485695,106244>init: job2 state changed from spawned to post-start
Aug 23 10:01:35 10 <1219485695,106880>init: job2 state changed from post-start to running
Aug 23 10:01:36 10 <1219485695,115608>init: Handling started event
Aug 23 10:02:53 10 <1219485773,443920>init: job2 main process (2163) killed by TERM signal
Aug 23 10:02:53 10 <1219485773,445212>init: job2 goal changed from start to stop
Aug 23 10:02:53 10 <1219485773,446308>init: job2 state changed from running to stopping
Aug 23 10:02:54 10 <1219485773,448668>init: Handling stopping event
Aug 23 10:02:54 10 <1219485773,450336>init: job2 state changed from stopping to killed
Aug 23 10:02:54 10 <1219485773,450948>init: job2 state changed from killed to post-stop
Aug 23 10:02:55 10 <1219485773,451548>init: job2 state changed from post-stop to waiting
Aug 23 10:02:55 10 <1219485773,454384>init: Handling stopped event
.
My understanding on "respawn limit 4 500" is as follows.
if the process is restarted more than 4 times within 500 seconds, the process should be stopped automatically.
This however does not happen.
Is this a bug?
If i use respawn without the limit option, the process gets respawned.

Thanks,
Sandeep

Question information

Language:
English Edit question
Status:
Answered
For:
upstart Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Scott James Remnant (Canonical) (canonical-scott) said :
#1

You still need a "respawn" stanza in there, "respawn limit" is a different stanza.

Can you help with this problem?

Provide an answer of your own, or ask Sandeep for more information if necessary.

To post a message you must log in.