[launchd-dev] Re: process dependancies

Joël Brogniart Joel.Brogniart at laposte.net
Mon Mar 12 03:26:30 PDT 2007


On Mar 11, 2007, at 10:39 AM, Joël Brogniart wrote:

>> A nice feature of SystemStartup is the notion of dependancies, ie  
>> the ability to spécify that a process is dependant of other  
>> processes. I don't see anything similar in launchd documentation.  
>> Do I have missed something in the doc or this feature doesn't  
>> exist with launchd?

Le 11 mars 07 à 19:45, Kevin Van Vechten a écrit :

> There's a relatively large conceptual change with launchd that can  
> easily be missed.

OK, so the feature was not so nice, but it was simple to understand.

>> The key concept to launchd is to use actual operating system  
> primitives for dependencies, not just names.  What does that mean?   
> Well, in practical terms, a process really doesn't depend on  
> another process unless it communicates with it in some way.  Let's  
> say you have a process that depends on the PostgreSQL database --  
> that essentially boils down to the process assuming that Postgres'  
> UNIX domain socket exists (/tmp/.s.PGSQL.4321).

> The launchd approach means that the Postgres property list  
> specifies that UNIX domain socket.  During startup, launchd  
> initializes all of the UNIX domain sockets, network sockets, mach  
> services, etc.  When your process runs, it can successfully connect  
> the Postgres socket.  This connection, in turn, triggers launchd to  
> start up Postgres on demand.  The calling process blocks until  
> Postgres bring-up

So, if I understood, lets me give an example.

I have a java web application that run with Tomcat. This java app  
respond on port 10001 with protocol AJP 1.3 and on port 10002 with  
protocol http.
I have an Apache server that connect to the web application with  
mod_jk (with protocol AJP).

In order to have Apache to wait until the web application is ready I  
have to include a "Sockets" and a "inetdCompatibility " keys in the  
web application launchd.plist:

	<key>ProgramArguments</key>
	<array>
		<string>/Library/Java/Home/bin/java</string>
		<string>-server</string>
		...
		<string>org.apache.catalina.startup.Bootstrap</string>
		<string>start</string>
	</array>
	<key>RunAtLoad</key>
	<true/>
	...
	<key>Sockets</key>
	<dict>
		<key>Listeners</key>
		<dict>
			<key>SockNodeName</key>
			<string>192.168.128.16</string>
			<key>SockServiceName</key>
			<array>
   				<integer>10001</integer>
   				<integer>10002</integer>
   			</array>
		</dict>
	</dict>
	<key>inetdCompatibility</key>
	<dict>
		<key>Wait</key>
		<false/>
	</dict>
	...

(mod_jk will likely fail with a timeout error due to the duration of  
the web application's initialisation but that's another topic). Is  
that right?

Joël Brogniart


More information about the launchd-dev mailing list