[launchd-dev] Daemon & Network Availability?
Karl Moskowski
kolpanic at voodooergonomics.com
Mon Nov 10 12:12:35 PST 2008
So, I've been doing a bit of research, and I've noticed a couple of
effects:
- for the launchd checkin process to succeed, the daemon's plist needs
a Sockets section and ServiceIPC=true
- at boot time, to have the daemon launch only when the network is
available, set RunAtLoad=false and KeepAlive={NetworkState=true}
These two are independent; if I omit the Sockets & ServiceIPC and
checkin in main(), then reboot with no network, the daemon starts
after I connect the ethernet cable.
There are few complications:
- launchd loads the daemon as soon as the network interface is
available, before it has a valid IP address.
- launchd loads the daemon at boot if any network interfaces are
connected (e.g., Parallels ports)
- launchd doesn't unload the daemon automatically if the network goes
down
To workaround the first two, I guess I could put a reachability test
in the initialization code of main() and exit if I can't get to the
server, allowing launchd to reload the daemon automatically. For the
last, I can also exit if the connection dies and let launchd control
resurrection.
What do you think?
----
Karl Moskowski <kolpanic at voodooergonomics.com>
Voodoo Ergonomics Inc. <http://voodooergonomics.com/>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2441 bytes
Desc: not available
URL: <http://lists.macosforge.org/pipermail/launchd-dev/attachments/20081110/746859ba/attachment-0001.bin>
More information about the launchd-dev
mailing list