[launchd-dev] Daemon & Network Availability?

Ned Hogan nedly at mac.com
Thu Nov 13 09:22:35 PST 2008


Thanks Quinn, this helps a lot, I, like Karl, had started going in the  
wrong direction thinking I could use Lanchd like inetd. Old habits die  
hard.

My daemon checks in with the server every 5 minutes, connection  
permitting, if we can't connect, try again next time. The server can  
make a connection anytime, but I don't really need to manage that with  
Launchd and it works just fine.

Using the OnDemand and QueueDirectory keys to manage my Agent is all  
that is required for basic operation as a LanchAgent and not a  
LaunchDaemon.

I plan to add support for Bonjour, which appears I would need to write  
a LaunchDaemon. The best example I can find in that regard is  
AppleVNCServer, but I can ask those questions on Bonjour-Dev.

MBP1524:PayLoad nedh$ ps -ax | grep VNC
    32 ??         0:00.02 /System/Library/CoreServices/ 
RemoteManagement/AppleVNCServer.bundle/Contents/Support/RFBRegisterMDNS
   120 ??         0:00.00 /System/Library/CoreServices/ 
RemoteManagement/AppleVNCServer.bundle/Contents/Support/ 
VNCPrivilegeProxy
   202 ??         0:00.05 /System/Library/CoreServices/ 
RemoteManagement/AppleVNCServer.bundle/Contents/MacOS/AppleVNCServer

Seems to me someone could make a few $$ writing a book just on Launchd.

Ned
On Nov 11, 2008, at 1:28 AM, Quinn wrote:

> I have a couple of comments and a couple of questions...
>
> At 12:46 -0500 10/11/08, Karl Moskowski wrote:
>> Thanks for the info, Ned. Would I need this if my daemon doesn't  
>> provide any networks services? (The daemon really just a client for  
>> a network service - I made it a daemon because it has to run  
>> without a user logged into Mac OS X.) What type of refactoring do  
>> you think would be required?
>
> All of the "check in with launchd" stuff is only necessary when  
> you're vending a service and you want to launch on demand.  If  
> you're connecting to a service, you shouldn't need it.
>
> Q1: Are you planning to launch on demand, or do you want to launch  
> at startup and keep running?
>
> A launchd daemon that's set to launch at startup will launch well  
> before the network comes up.  Keep in mind that the network may / 
> never/ come up, or may come up and go down (repeatedly even), so  
> it's not a case of simply waiting for the network to come up, you  
> have to track the network state.
>
> Q2: Do you want to be running even if there's no possibility of  
> connecting to your network service?
>
> S+E
> -- 
> Quinn "The Eskimo!"                    <http://www.apple.com/developer/ 
> >
> Apple Developer Relations, Developer Technical Support, Core OS/ 
> Hardware
> _______________________________________________
> launchd-dev mailing list
> launchd-dev at lists.macosforge.org
> http://lists.macosforge.org/mailman/listinfo.cgi/launchd-dev



More information about the launchd-dev mailing list