init script

Jeremy Lavergne jeremy at lavergne.gotdns.org
Mon Mar 26 16:48:46 PDT 2012


>> * a script to start and stop the service can basically create two KeepAlive:SuccessfulExit jobs
> 
> Maybe I'm misunderstanding the man page (or not creative enough), but I don't see how that would work...

The way I read that is the system can be told to run the start script at load, and only run it once provided it exits successfully (`load -w` for it to be run at boot). You can then load the stop script's launchd program whenever you want to stop the daemon these scripts control (`load -F` to be loaded on demand). Provided the stop script exits cleanly, it will only be run once as well.

>> * restart-netchange is easily handled by KeepAlive:NetworkState
> 
> probably, although it's not exactly the same thing (eg, this is set for bind9 so that when new addresses appear it's restarted and can listen on them - it looks like KeepAlive:NetworkState will bring the job up when a single IPv4 or IPv6 address is assigned to an interface and not restart it if more are assigned later).

That sounds correct---a simple check that a device has an IP.

One thing I noticed is this one fires on wake if you're using a wifi connection, since the connection is restored after the machine is fully awake.

>> * restart-wakeup and restart-dist-notify are not a single port
>> 
>> In fact from a few greps, it seems most of the advanced uses for daemondo aren't utilized at all.
> 
> 
> since most of the macports software is ported from systems where the startup/launching stuff is significantly less featureful, that's not surprising.
> 
> It's also worth noting that the KeepAlive stuff isn't in the man page on 10.5 (I don't have a 10.6 box handy to check if it's there or if it showed up with 10.7).
> 
> I'm all for using launchd directly where it we can, though.

I'm all for it as well, but want to make sure there aren't many more cases than I can think of where it's a bad idea. The man pages in 10.6 and 10.7 list out the same instances where launchd cannot be used, if the program will:
 * call daemon(3).
 * do the moral equivalent of daemon(3) by calling fork(2) and have the parent process exit(3) or _exit(2).

Several KeepAlive keys showed up or were renamed in 10.6, but there might be some on 10.5 nonetheless: was the manpage you checked `man launchd.plist`?

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 8796 bytes
Desc: not available
URL: <http://lists.macosforge.org/pipermail/macports-users/attachments/20120326/87425220/attachment.bin>


More information about the macports-users mailing list