The Old Blog Archive, 2005-2009

launchd ain’t like no daemons

It turns out that launchd, Apple’s take of rc.d and all those init stuff, doesn’t like daemons. For the traditional services to be launched by launchd as a daemon, you have to first turn off the “daemonize” option, and let launchd takes care of it for you.

So as things migrate from StartupItems to LaunchDaemons, many packages of MacPorts (formerly known as DarwinPorts) have followed suite. The problem is some services only come with daemon mode. So MacPorts comes up with a helper utility called daemondo, which launches the daemon in another process and monitors its starting up, so as to pamper launchd.

mongrel_cluster_ctl, in this case, requires daemondo (mongrel_rails comes with no-daemon mode though), because it spawns a number of mongrel processes in a daemon-like way, which launchd doesn’t like. Copy any script that involves daemondo, and turns every debug message on. Tracing launchd can be a tricky thing, you’ll need every verbosity at hand. And just skip any script that does not mention the keyword daemondo–they are guaranteed not to work.

Comments are closed.