Questions on mixed triggers and calendar triggers
I've read some WWDC sessions slides, the launchd.plist man page and I've already made some launchd plists but I'm wondering about the following points: - is it possible to define different types of trigger for a launchd daemon or agents? For instance, is it possible to launch a daemon both on schedule with StartCalendarInterval and a mach message? The idea being the process would be run at a specific time of the day but could also be launched "manually". - is there a way to change the StartCalendarInterval values of a daemon launchd plist (while the launchd daemon is running) with some kind of launchd APIs instead of Foundation/CoreFoundation APIs? If you change these values, do you need to unload and then reload the plist (I would tend to believe so which would be an issue)? - is it possible tell launchd to re-launch a schedule daemon if the daemon crashes and not only when the next trigger date is reached?
On Thu, Jul 22, 2010 at 11:01 PM, Iceberg-Dev <dev.iceberg@gmail.com> wrote:
I've read some WWDC sessions slides, the launchd.plist man page and I've already made some launchd plists but I'm wondering about the following points:
- is it possible to define different types of trigger for a launchd daemon or agents?
For instance, is it possible to launch a daemon both on schedule with StartCalendarInterval and a mach message? The idea being the process would be run at a specific time of the day but could also be launched "manually".
- is there a way to change the StartCalendarInterval values of a daemon launchd plist (while the launchd daemon is running) with some kind of launchd APIs instead of Foundation/CoreFoundation APIs? If you change these values, do you need to unload and then reload the plist (I would tend to believe so which would be an issue)?
For this one id suggest you launch your daemon more frequently. Then add a start up / initialization check that determines whether the daemon should run. That way, you can dial it back yourself. For example if your startcalendarinterval was scheduled to run 1 time every hour. Then the daemon doesnt have to do anything, it can just quit until / unless the n*th invokation. Thats probably a lot easier than messing around with the Apple APIs.
- is it possible tell launchd to re-launch a schedule daemon if the daemon crashes and not only when the next trigger date is reached?
_______________________________________________ launchd-dev mailing list launchd-dev@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/launchd-dev
On Jul 22, 2010, at 3:01 PM, Iceberg-Dev wrote:
I've read some WWDC sessions slides, the launchd.plist man page and I've already made some launchd plists but I'm wondering about the following points:
- is it possible to define different types of trigger for a launchd daemon or agents?
Yes. launchd ORs criteria together. So if it can find an excuse to kick your job off, it will.
For instance, is it possible to launch a daemon both on schedule with StartCalendarInterval and a mach message? The idea being the process would be run at a specific time of the day but could also be launched "manually".
Yes. Though why would you want your daemon to run on a timer interval if you can just launch it on-demand whenever you need to?
- is there a way to change the StartCalendarInterval values of a daemon launchd plist (while the launchd daemon is running) with some kind of launchd APIs instead of Foundation/CoreFoundation APIs?
The property list format is defined at the CoreFoundation layer. So no.
If you change these values, do you need to unload and then reload the plist (I would tend to believe so which would be an issue)?
Why do you need to change this value?
- is it possible tell launchd to re-launch a schedule daemon if the daemon crashes and not only when the next trigger date is reached?
See the KeepAlive section of launchd.plist(5), specifically, SuccessfulExit. -- Damien Sorresso BSD Engineering Apple Inc.
On Jul 23, 2010, at 9:27 AM, Damien Sorresso wrote:
On Jul 22, 2010, at 3:01 PM, Iceberg-Dev wrote:
For instance, is it possible to launch a daemon both on schedule with StartCalendarInterval and a mach message? The idea being the process would be run at a specific time of the day but could also be launched "manually".
Yes. Though why would you want your daemon to run on a timer interval if you can just launch it on-demand whenever you need to?
If you change these values, do you need to unload and then reload the plist (I would tend to believe so which would be an issue)?
Why do you need to change this value?
Let's imagine you have a solution to check for updates. Let's call it Software Update. You may want to check for updates on a regular basis and you may want the user to check for update whenever (s)he wants. You may also want to do some load balancing for your server update. So it might be nice if not every single user would check for updates at the same time when the check is performed on schedule. So for instance, you may want to: - schedule the first check during the installation by dynamically setting the next calendar date. - perform checks every xx hours. When a check is performed, you want the next check to occur xx hours after the current one. - when a manual check has been performed. Run the next scheduled check xx hours after the manual check.
participants (3)
-
Damien Sorresso
-
Dreamcat4
-
Iceberg-Dev