The preferred way to launch processes at boot/login in OS X since 10.4 is to 
use launchd. From <>, "The 
launchd daemon takes over many tasks from cron, xinetd, mach_init, and init, 
which are UNIX programs that traditionally have handled system initialization, 
called system scripts, run startup items, and generally prepared the system for 
the user."

All well and good. It's a nice service and reasonably easy to manage, 
especially when using something like Lingon 
<>. However, launchd has one 
feature that is annoyingly incompatible with Resin 4.x; it kills all child 
processes that the first process started when the first process exits.

Unfortunately, from what I can tell, this is exactly what Resin 4.x does. The 
ResinBoot class is responsible for creating the WatchDog process, and the 
WatchDog is what creates and then monitors the main Resin process, but after 
the WatchDog starts, ResinBoot exits so launchd kills the child processes.

So what's a girl to do? I don't know. I'm not a girl. But here's what I did.

Buried down in an Apple Developer Connection document, Daemons and Agents, is a 
section titled "Careful With That Fork, Eugene" <>. That's 
the section that explains how launchd will kill child processes if the original 
process exits. But it also lists a few work-arounds. The first two are specific 
to daemon and probably not doable for Resin, at least not without mucking 
around with Resin and rebuilding it. But the third, and of course the 
"least-preferable" by Apple's standards, is to use the AbandonProcessGroup 
property in Resin's startup plist file.


Once you have your .plist file created (easy with Lingon), you can either edit 
it directly (it should be in /Library/LaunchDaemons), or within Lingon switch 
into "Expert Mode" and choose the AbandonProcessGroup parameter from the 
"Insert parameter..." drop down. It will look like this in the plist file:


Here's the definition of AbandonProcessGroup:

AbandonProcessGroup <boolean>
When a job dies, launchd kills any remaining processes with the same process 
group ID as the job. Setting this key to true disables that behavior.

I can't say this is the best/only solution, but it worked for me.


resin-interest mailing list

Reply via email to