[launchd-dev] launchd - how to specify daemon needs to wait for network to start?

Dave Zarzycki zarzycki at apple.com
Tue Apr 22 08:55:53 PDT 2008


Jim,

The correct way is to modify the p4d to utilize the  
SystemConfiguration framework that Apple provides. That will let a  
developer monitor all forms of network state transitions. If that is  
temporarily impractical, one can wrap the invocation of p4d with a  
shell script:

#!/bin/sh

# ipconfig "waitall" might go away in a future release.
# we really need p4d to adopt the SystemConfiguration framework
/usr/sbin/ipconfig waitall

exec /usr/local/bin/p4d



davez


On Apr 22, 2008, at 7:19 AM, Jim Correia wrote:

> I'm upgrading a server from 10.4 to 10.5 server. This server runs  
> p4d (which really wants to listen/fork itself - there are  
> restrictions on (x)inetd compatibility mode), and a handful of other  
> jobs which should only be running after the p4d daemon has started.
>
> Currently, the launchd job is specified like this:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd 
> ">
> <plist version="1.0">
> <dict>
> 	<key>KeepAlive</key>
> 	<dict>
> 		<key>NetworkState</key>
> 		<true/>
> 	</dict>
> 	<key>Label</key>
> 	<string>com.perforce.p4d</string>
> 	<key>ProgramArguments</key>
> 	<array>
> 		<string>/usr/local/bin/p4d</string>
> 		...
> 	</array>
> </dict>
> </plist>
>
> It appears that p4d is first launched before the network interface  
> is up. (The error information in the log isn't extremely verbose. It  
> looks like it is trying to bind to the address in the license file,  
> and this fails.) After one or more respawn attempts, the server comes.
>
> What is the correct way to spec the job?
>
> Jim
> _______________________________________________
> launchd-dev mailing list
> launchd-dev at lists.macosforge.org
> http://lists.macosforge.org/mailman/listinfo/launchd-dev



More information about the launchd-dev mailing list