[15:26] <fbond> "start on started rc2" doesn't really do what I want.
[15:49] <fbond> I think what I want to do would require the rc2 job to emit an event like "rc2-finished".  This is different from "stopped rc2" because that happens regardless of whether or not rc2 was killed due to switching runlevels or rc2 finished normally (and we're in runlevel 2).
[15:49] <fbond> Am I thinking about this wrong?
[15:50] <fbond> Can I do conditional "start on " directives?
[15:50] <fbond> Like "start on runlevel 2 and stopped rc2"?
[15:50] <fbond> That doesn't seem like it would work because it's not an event that happens at a specific time...
[15:53] <sadmac2> fbond: I believe the stopped event has an environment variable (I think its RESULT) that says whether it was a success or a failure
[15:53] <sadmac2> fbond: so start on stopped rc2 RESULT=ok
[15:54] <fbond> sadmac2: My only concern is a race condition.
[15:55] <sadmac2> fbond: what race condition?
[15:55] <fbond> If we go into runlevel 2 and then switch to runlevel 3 before rc2 has totally finished, is it not at all possible that some odd timing (rc2 finishes just after we enter runlevel 3) will lead to me receiving the events out of order?
[15:56] <fbond> Let me be more explicit:
[15:56] <fbond> I want a job with:
[15:56] <fbond> start on stopped rc2 RESULT=ok
[15:56] <fbond> stop on runlevel [!2]
[15:56] <fbond> This will make sure the job doesn't get started until after the rc2 init scripts have finished.
[15:57] <sadmac2> those two lines should do it
[15:57] <fbond> But what if rc2 init scripts finish normally just after runlevel 3 is entered but before upstart kills rc2?
[15:57] <fbond> Is that not possible?
[15:58] <fbond> If that happened, my job would be running in runlevel 3.
[15:58] <fbond> (Sorry if I'm making this overly complicated.  I'm just wondering what does upstart do to prevent this?)
[15:59] <sadmac2> I don't know that that can happen
[16:00] <fbond> I think it can...
[16:00] <sadmac2> but I'm not certain now...
[16:00] <fbond> Because runlevel 3 is an event, so it happens before upstart kills rc2.
[16:00] <fbond> That leaves a brief window for things to go wrong (unless I'm missing something).
[16:02] <sadmac2> fbond: upstart is single-threaded internally, so I think that the normal exit of rc2 and the runlevel event would be serialized
[16:02] <sadmac2> fbond: if the runlevel event happened first, upstart would register rc2 as "killed" even though it had terminated successfully
[16:02] <sadmac2> I think
[16:02] <fbond> sadmac2: The runlevel event *must* happen first, right?
[16:02] <fbond> Because rc2 has "stop on runlevel [!2]"
[16:03] <fbond> sadmac2: Okay, is upstart smart enough to say "rc2 failed because I would have killed it"?
[16:03] <fbond> Time to look at the source I guess...
[16:03] <sadmac2> fbond: its more dumb enough I think :)
[16:04] <fbond> sadmac2: ;)
[16:05] <fbond> Any idea where in the source I ought to look?
[16:05] <fbond> This is hard to grep for :)
[16:06] <sadmac2> fbond: init/job.c will be helpful
[16:06] <fbond> sadmac2: thanks
[16:08] <fbond> sadmac2: Doesn't look good.
[16:09] <fbond> job_child_reaper appears to set the job status as failed based on process exit status.
[16:09] <fbond> That doesn't take into account what upstart may have wanted to do to the process. ;)
[16:10] <sadmac2> fbond: but that's fine
[16:10] <fbond> It is?
[16:10] <sadmac2> fbond: because the runlevel event hasn't been processed at all yet
[16:10] <sadmac2> fbond: so runlevel 3 hasn't been received by anything
[16:10] <fbond> I don't see how.
[16:10] <sadmac2> fbond: upstart can only be doing one thing at a time
[16:11] <fbond> You are saying the event has been emitted but not finished processing?
[16:11] <sadmac2> fbond: not even started processing.
[16:11] <fbond> That can't be true.
[16:11] <fbond> Because stopping rc2 happens in response to the runlevel 3 event.
[16:11] <fbond> Right?
[16:11] <sadmac2> fbond: that's a different case though :)
[16:11] <fbond> I'm not sure I follow you.  I've been talking about the same case the whole time. ;)
[16:13] <fbond> sadmac2: Do we agree that there is a race in that particular case?
[16:13] <sadmac2> fbond: for your race condition, either the child is reaped before the runlevel event is processed (in which case it appears rc2 finished before runlevel was ever emitted) OR the runlevel event is processed before the child is reaped (in which case upstart tries to kill it anyway and just registers a failure)
[16:14] <fbond> sadmac2: There is a third case.
[16:14] <fbond> The process dies just before upstart tries to kill it.
[16:14] <fbond> The failure isn't registered because the process exited normally.
[16:15] <sadmac2> fbond: upstart should call it a failure if it explicitly killed something
[16:15] <sadmac2> fbond: and I think it won't even wait for the reap result.
[16:16] <fbond> sadmac2: That's not what the code I'm looking at says (unless I'm missing something).
[16:16] <sadmac2> fbond: I have to be somewhere. I'll be back a bit later
[16:16] <fbond> If you reviewed the code and told me I was wrong I would be exceedingly pleased.
[16:16] <fbond> sadmac2: Okay, no worries.
[16:24] <sadmac2> fbond: ah, looks like I have more time than I thought
[16:25] <fbond> sadmac2: Good for you. ;)
[16:26] <fbond> sadmac2: BTW, I'm looking at upstart source from Hardy (0.3.9-2).
[16:26] <sadmac2> fbond: ohh
[16:26] <sadmac2> fbond: I was looking at 0.5.0
[16:26] <sadmac2> hold on...
[16:44] <sadmac2> fbond: ok, the RESULT variable is new in 0.5.0
[16:44] <sadmac2> so that won't work :)
[16:45] <fbond> sadmac2: Ah.  So I should just write an init script, I guess.
[16:45] <sadmac2> fbond: that's an option
[16:45] <sadmac2> probably the best option
[16:46] <fbond> sadmac2: Okay, KISS, I guess.
[16:46] <sadmac2> heh
[16:46] <fbond> sadmac2: Too bad, though.
[16:46] <fbond> I just want upstart to take over already.
[16:46] <fbond> Can't use it to replace an init script until all of the init scripts are gone.
[16:46] <fbond> That's a bummer.
[16:48] <fbond> sadmac2: I think that still leaves an obvious use case for upstart that is not well supported ... ?
[16:48] <fbond> sadmac2: But I won't be needing it for my current project.
[16:48] <fbond> sadmac2: Thanks for your help!
[16:49] <sadmac2> fbond: np
[23:19] <keesj> fbond: itsn't that a contraditon ?
[23:21] <keesj> fbond: I was reading the backlog. I see you found something