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

Jerry Krinock jerry at ieee.org
Sun Nov 16 13:59:27 PST 2014


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

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.

> 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 :)



More information about the launchd-dev mailing list