Excerpts from Steve Langasek's message of 2014-01-07 10:25:12 -0800: > On Mon, Jan 06, 2014 at 10:45:31PM -0500, Stéphane Graber wrote: > > > It seems like most of the examples in the Cookbook recommend that if you > > > want to stop a job in the pre-start stanza, you should call "stop" which > > > will handle stopping the job for you. But, it seems looking at the > > > Upstart code I can just as easily return a negative return value to > > > cause the job to stop: > > > > http://bazaar.launchpad.net/~upstart-devel/upstart/trunk/view/head:/init/job.c#L417 > > > > Is there a reason I should call "stop" over just returning a negative > > > value? > > > Calling { stop; exit 0; } also means the job won't be considered as failed. > > > Returning non-zero will log an error in the log file and prevent any job > > depending on the current job from starting (which may or may not be what > > you want). > > > So in short, exitting non-zero or calling stop+exit are two different > > things with different behaviours, you have to choose which you want. > > A job depending on the current job won't start if you call 'stop' from the > pre-start, either - because a depending job will have 'start on started > foo', and the 'started' event will not be emitted for a job stopped from the > pre-start. >
I did the following test: /etc/init/test-block.conf pre-start script sleep 5 exit 1 end script /etc/init/test-block-slave.conf start on starting test-block script env > /tmp/env.$$ end script /tmp/env.$$ ended up as: UPSTART_INSTANCE= INSTANCE= UPSTART_JOB=test-block-slave TERM=linux PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin UPSTART_EVENTS=starting PWD=/ JOB=test-block Consequently when I changed it from 'exit 1' to 'stop' (and thus, exit 0) the slave started exactly the same. So if you need something _started_ you should use the started event. If you need to start before something, you should use the _starting_ event. But I don't think you can depend on something "after pre-start succeeds but before started". For that you need the other job to emit an event in pre-start on success. Note that it probably wouldn't be hard to have upstart emit a pre-started, but I question the need for such a thing. -- upstart-devel mailing list [email protected] Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/upstart-devel
