Hi, 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? Regards. Joël Brogniart
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?
Hi Joël, There's a relatively large conceptual change with launchd that can easily be missed. With SystemStarter, a "dependency" was merely a means to order the execution of StartupItem scripts. It was more flexible, but not more powerful, than executing a set of scripts in a directory in lexical order. The became problematic when a script changed between releases (due to underlying technology changes). The behavior you got while depending on "Network" in 10.2 might not exactly correspond to the behavior you got while depending on "Network" on 10.3. 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 is complete, then Postgres services the request, and the "dependency" has been fulfilled. It's akin to virtual memory paging -- where a large address space is always virtually available, and actual use of pages cases the page to be brought into memory as necessary. Launchd strives to make all system services virtually available, and start them as they are required. - Kevin
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
On Mar 12, 2007, at 3:26 AM, Joël Brogniart wrote:
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?
Is is right? Definitely not. Use of the "Sockets" key generally involves changes in the target program. In this case, the Java runtime engine and THEN your Java code. I have yet to see a Java runtime engine modified to be launchd aware. Sorry, davez
Le 13 mars 07 à 03:47, Dave Zarzycki a écrit :
Is is right? Definitely not. Use of the "Sockets" key generally involves changes in the target program. In this case, the Java runtime engine and THEN your Java code. I have yet to see a Java runtime engine modified to be launchd aware.
So, SystemStartup items dependancies management is not so bad :-) At least with all the non launchd aware applications out there or for teams that don't dispose of enougth human resources nor competences to rewrite a launchd aware version of a tool. I don't have the competences to rewrite a JRE neither Tomcat, nor the Java web application I manage :-( I'm just a system administrator which try his best to make all these tools to work together and start correctly after a server restart. Thanks for your patience and informative responses. Cheers. Joël
participants (3)
-
Dave Zarzycki
-
Joël Brogniart
-
Kevin Van Vechten