[launchd-dev] What is "Service only ran for XX seconds … Pushing respawn out …"

Damien Sorresso dsorresso at apple.com
Mon Nov 17 08:04:55 PST 2014


On 16 Nov, 2014, at 13:59, Jerry Krinock <jerry at ieee.org> wrote:
>> On 2014 Nov 16, at 13:42, Damien Sorresso <dsorresso at apple.com> wrote:
>> 
>> It's likely that your job is being relaunched because your WatchPath criterion is firing.
> 
> Thank you, Damien.  That’s probably true.
> 
>> Your ThrottleInterval is 60, which means that launchd will require that your job run for at least 60 seconds. If it does not, then launchd will not spawn it again until 60 seconds have passed since the last time it was run. (This is to amortize startup costs.) This behavior is described in launchd.plist(5).
> 
> It looks like I am using ThrottleInterval just a little differently than what the its designers had in mind.  My tool gets its input from stdin, only when it launches.  I want ThrottleInterval to *coalesce* and simply *delay* reactions to triggers that occur within the ThrottleInterval of the prior trigger.  My tool does not “linger" when the work is done because it is not a “service” that needs to jump on every trigger immediately.  Instead of amortizing, it ignores.  I am truly using ThrottleInterval as a “throttle”, not as a way to amortize startup costs.
> 
> So it works as I intend, except that it prints this unnecessary and, I think, somewhat misleading message to the console whenever it runs.  When I read “Pushing respawn out by 35 seconds”, I think that an actual respawn has been scheduled, but in fact it is only hypothetical.  That log message really means “If (as in “big if”) another trigger occurs within the next 35 seconds, respawning of your job will be delayed until 35 seconds from now”.  That’s what I want, not a problem.

Actually, that message is printed if we try and spawn the job but found that it did not run for the requisite minimum time. So the message pretty much means what it said: "I went to spawn you, but you said you need to run for 60 seconds at minimum, and you only ran for 35 seconds last time, so I'm pushing your next spawn out by 25 seconds to emulate that expectation."

If no spawn attempt was made, that message does not get printed.

> Is there a better technique than ThrottleInterval to get what I want?  If not, do you think Apple might entertain a Bug requesting that the confusing and unnecessary log entries not be made?  I noticed another app produced one of them earlier today too.

I'm not sure I'm grokking what you're after to be honest.

>> You can see why launchd spawned your job on Yosemite by using the `launchctl print` subcommand. See the launchctl(1) man page for details. In that output will be the reason launchd ran the job (if the job is currently running).
> 
> Very nice; anything to reduce the opacity of launchd is appreciated!  This might also be a good place to print that respawn delay information :)

It should be there, printed under "minimum runtime".
-damien



More information about the launchd-dev mailing list