tag:blogger.com,1999:blog-637417304187784899.post9124622820857526029..comments2024-01-04T09:04:42.121+00:00Comments on James Strachan's Blog: Running Nexus with launchd on OS XJames Strachanhttp://www.blogger.com/profile/12591119339035350067noreply@blogger.comBlogger5125tag:blogger.com,1999:blog-637417304187784899.post-77968099819596540112010-03-27T23:10:24.254+00:002010-03-27T23:10:24.254+00:00My first try at a launchd plist. I spent a little ...My first try at a launchd plist. I spent a little time with this and thought I would add my lessons learned. I created a nexus user on my computer just for the nexus app and repo. I wanted nexus to start on system start and without anyone logged in so other computers could hit it when I was not logged in.<br /><br />I created a /Library/LaunchAgents directory and got the following error: <i>launchctl: Dubious ownership on file (skipping): /Library/LaunchAgents</i>. Needed to sudo chown root:wheel /Library/LaunchAgents.<br /><br />I had permission problems and ended up making the plist root:wheel 644. I set run as nexus (user) in both the plist and the nexus conf.<br /><br />When trying to load sonatype.nexus, I would get: <i>launchctl: no plist was returned for: /Library/LaunchAgents/sonatype.nexus.plist</i>. I had fat-fingered an end tag and had invalid xml. Fixed that.<br /><br />Next, on load from computer restart, the system.log showed that it appeared to run but was not running when I logged in. I found that launchd garbage collects child processes for security reasons (hates forkers). I added AbandonProcessGroup to inhibit this.<br /><br />Last, <a href="http://sourceforge.net/projects/lingon/files/" rel="nofollow"> Lingon</a> is a pretty simple way to manage these plists.<br /><br />Here is the plist that I ended up putting in /Library/LaunchDaemons/<br /><br /><br /><?xml version="1.0" encoding="UTF-8"?><br /><!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"><br /><plist version="1.0"><br /><dict><br /> <key>Label</key><br /> <string>sonatype.nexus</string><br /> <key>ProgramArguments</key><br /> <array><br /> <string>/Users/nexus/nexus-webapp-1.5.0/bin/jsw/macosx-universal-32/nexus</string><br /> <string>start</string><br /> </array><br /> <key>RunAtLoad</key><br /> <true/><br /> <key>UserName</key><br /> <string>nexus</string><br /> <key>LaunchOnlyOnce</key><br /> <true/><br /> <key>AbandonProcessGroup</key><br /> <true/><br /></dict><br /></plist>Steve Tarverhttps://www.blogger.com/profile/04122947130689804313noreply@blogger.comtag:blogger.com,1999:blog-637417304187784899.post-4301197469861170442009-11-02T09:21:45.007+00:002009-11-02T09:21:45.007+00:00I've just noticed that the plist uses the star...I've just noticed that the plist uses the <em>start</em> argument. This will cause the wrapper to fork, which launchd doesn't like. The net effect is that it'll start nexus once, but you won't be able to control it thereafter.<br /><br />If you change it to <em>console</em> then everything works as expected:<br /><br />$ launchctl load ~/Library/LaunchAgents/Nexus.plist<br><br />$ launchctl stop com.sonatype.nexus<br><br />$ launchctl start com.sonatype.nexusUnknownhttps://www.blogger.com/profile/03475054917620813815noreply@blogger.comtag:blogger.com,1999:blog-637417304187784899.post-40433902303102627982009-07-02T03:36:29.304+00:002009-07-02T03:36:29.304+00:00Looks like you have to first:
launchctl load ~/Li...Looks like you have to first:<br /><br />launchctl load ~/Library/LaunchAgents/sonatype.nexus.plist<br /><br />then:<br /><br />launchctl start sonatype.nexus<br /><br />Or I suppose add the .plist and log out/in.Jasonhttps://www.blogger.com/profile/03035461669561831915noreply@blogger.comtag:blogger.com,1999:blog-637417304187784899.post-47852878935523452642008-08-29T08:09:00.000+00:002008-08-29T08:09:00.000+00:00Please do!I guess keeping it running all the time ...Please do!<BR/><BR/>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.James Strachanhttps://www.blogger.com/profile/12591119339035350067noreply@blogger.comtag:blogger.com,1999:blog-637417304187784899.post-9721034243903886382008-08-29T01:23:00.000+00:002008-08-29T01:23:00.000+00:00Hi James, mind if we include this in the Nexus bun...Hi James, mind if we include this in the Nexus bundle going forward?Brian Foxhttps://www.blogger.com/profile/02303803710473503355noreply@blogger.com