init script

Daniel J. Luke dluke at geeklair.net
Mon Mar 26 16:53:20 PDT 2012


On Mar 26, 2012, at 7:48 PM, Jeremy Lavergne wrote:
>>> * 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.

oh, ok - seems like that's kind of confusing though (there would be a job that you would load to start the service and another that you would load to stop it?)

Stuff that started/stopped without custom scripts are going to be annoying anyway though...

>>> * 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`?

yep, KeepAlive isn't even in the man page on 10.5 (10.5 is two release ago now, though, so maybe we don't care too much for this effort...)

--
Daniel J. Luke                                                                   
+========================================================+                        
| *---------------- dluke at geeklair.net ----------------* |                          
| *-------------- http://www.geeklair.net -------------* |                          
+========================================================+                        
|   Opinions expressed are mine and do not necessarily   |                          
|          reflect the opinions of my employer.          |                          
+========================================================+





More information about the macports-users mailing list