Thursday, 28 August 2008

Running Nexus with launchd on OS X

I've finally got Nexus running for maven builds to help boost the speed downloading and checking repos etc.

This gave me the excuse to finally take a quick look at using launchd which is the preferred OS X way to run daemons and services. First look it appears cool and much nicer than rc/init.d/xinit.d et al.

Here's a really simple always-run nexus script, sonatype.nexus.plist. Just drop it into your ~/Library/LaunchAgents/ directory and you should be good to go.

From the command line you can then do this if you want to boot it up straight away - but it should restart on reboot (which I'll test out next time I've gotta reboot :)
launchctl start sonatype.nexus
I did try get clever and wait for port 8081 to be used before booting up nexus but couldn't get it to work properly so figured just starting it up on boot was easier :)

Update: BTW the script is available under the Apache License 2.0 if anyone wants to copy it or include it in any distro of Nexus

3 comments:

Brian Fox said...

Hi James, mind if we include this in the Nexus bundle going forward?

James Strachan said...

Please do!

I guess keeping it running all the time on startup is maybe simpler than doing the on-demand-wait-for-port-8081 to be used etc.

Jason said...

Looks like you have to first:

launchctl load ~/Library/LaunchAgents/sonatype.nexus.plist

then:

launchctl start sonatype.nexus

Or I suppose add the .plist and log out/in.