launchd - how to specify daemon needs to wait for network to start?
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
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@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo/launchd-dev
On Apr 22, 2008, at 11:55 AM, Dave Zarzycki wrote:
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
Thanks Dave, that solves the problem. Modifying p4d is impractical since it is closed source commercial software that we license. I'm currently on an older release. If the current release has the same issue, I'll log an enhancement request with Perforce. Jim
Though I've not used it on Mac OS, as a perforce admin I can definitely state that this is how perforce will continue to work: It's hard licensed to an IP address, so if that IP address does not exist on the server when the server is started, the licensing will fail, which is what you're seeing. (This is fairly common for commercial software: perhaps we can write something that DOES use SystemConfiguration as a generic exec wrapper?) (Note that the issue is only that the IP has to exist at process license verification: it'll still bind to *, so it doesn't need to ALWAYS exist, it only needs to exist at startup, so the wrapper (or the waitall wrapper below) should be fine.....) Dana Lacoste On Apr 22, 2008, at 09:07, Jim Correia wrote:
On Apr 22, 2008, at 11:55 AM, Dave Zarzycki wrote:
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
Thanks Dave, that solves the problem.
Modifying p4d is impractical since it is closed source commercial software that we license. I'm currently on an older release. If the current release has the same issue, I'll log an enhancement request with Perforce.
Jim
_______________________________________________ launchd-dev mailing list launchd-dev@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo/launchd-dev
participants (3)
-
Dana Lacoste
-
Dave Zarzycki
-
Jim Correia