2

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.

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.