Discussion:
[launchd-dev] launchd - how to specify daemon needs to wait for network to start?
Jim Correia
2008-04-22 12:16:35 UTC
Permalink
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
Dave Zarzycki
2008-04-22 13:54:16 UTC
Permalink
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
Post by Jim Correia
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.
<?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
http://lists.macosforge.org/mailman/listinfo/launchd-dev
Jim Correia
2008-04-22 14:05:43 UTC
Permalink
Post by Dave Zarzycki
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
#!/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
Dana Lacoste
2008-04-22 15:03:39 UTC
Permalink
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
Post by Jim Correia
Post by Dave Zarzycki
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
#!/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
http://lists.macosforge.org/mailman/listinfo/launchd-dev
Loading...