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

Jerry Krinock jerry at ieee.org
Mon Nov 17 08:45:03 PST 2014


> On 2014 Nov 17, at 11:04, Damien Sorresso <dsorresso at apple.com> wrote:
> 
> I'm not sure I'm grokking what you're after to be honest.

Yes I agree.  Please allow me to try again, from scratch…

My requirement is to read data from a watched file and process it whenever that file changes.  Such a change typically occurs only several times a day, often in bursts of several changes during a few minutes.  Some days there may be no changes at all.  Furthermore, my processing is not urgent.  If the watched file changes three times within a minute, I can be lazy and process all changes at once, a minute or two after the third change has completed.

It seems that having a service (process) running 24/7 for this need would be wasteful.  Instead, I use launchd with a WatchPath to launch the tool whenever a change is detected.  Furthermore, I use ThrottleInterval to coalesce multiple changes into one running of my tool.  Finally, my tool does not even have anything like a run loop to keep it running.  It just has a main() that reads the file, processes the data, and exits, typically after 10 seconds.

So you see there is no “requisite minimum time” for my program to run.  The faster it runs, the better!

* * *

The issue is that the ThrottleInterval gives me these warnings, because it is geared toward “amortizing startup”, instead of minimizing running.  Should I be doing things differently?

Thanks,

Jerry



More information about the launchd-dev mailing list