3

I want to be able to run Sonatype Nexus as a service on the Mac. It comes with the Java Service Wrapper start scripts for the mac so I basically have a shell script that can start the server.

I believe I have to add some sort of setup to /etc/launchd.conf and maybe use launchctl. All documentation I found points to plist files though but I don't have such a file for Nexus.

Manfred Moser
  • 173
  • 1
  • 7

1 Answers1

2

The preferred way to start services on OS X is with launchd. Basically, you create a .plist file that describes what needs to be run, and when, and put the file in /Library/LaunchDaemons. The tricky thing is that launchd expects to be able to monitor the daemon, so it doesn't like things that drop into the background; if I understand nexus right, that means running it in console mode rather than "start"ing it as you would on most systems. I think this is about what you'll need to have in the file (you may need to adjust the path to the executable):

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>com.sonatype.nexus</string>
    <key>ProgramArguments</key>
    <array>
        <string>/usr/local/nexus/bin/jsw/macosx-universal-32/nexus</string>
        <string>console</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
</dict>
</plist>

Save that as /Library/LaunchDaemons/com.sonatype.nexus.plist, set the ownership to root:wheel and permissions to 644. To activate it, either reboot or run the command sudo launchctl load /Library/LaunchDaemons/com.sonatype.nexus.plist.

Gordon Davisson
  • 11,036
  • 3
  • 27
  • 33