Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I've installed CouchDB via MacPorts. Now I want to start it when my Mac boots, so I executed the instructions given in the install process:

sudo launchctl load -w /Library/LaunchDaemons/org.apache.couchdb.plist

However this doesn't seem to work. I've looked inside the LaunchDaemons directory, and the plist file is there (as a symlink):

lrwxr-xr-x  1 root  wheel   57 18 aug 10:11 org.apache.couchdb.plist -> /opt/local/Library/LaunchDaemons/org.apache.couchdb.plist

The contents of the actual plist file seem ok (however I have no real knowledge of how it should look):

<plist version="1.0">
  <dict>
    <key>Label</key>
    <string>org.apache.couchdb</string>
    <key>EnvironmentVariables</key>
    <dict>
      <key>HOME</key>
      <string>~</string>


    </dict>
    <key>ProgramArguments</key>
    <array>
      <string>/opt/local/bin/couchdb</string>
    </array>
    <key>UserName</key>
    <string>couchdb</string>
    <key>StandardOutPath</key>
    <string>/dev/null</string>
    <key>StandardErrorPath</key>
    <string>/dev/null</string>
    <key>RunAtLoad</key>
    <true/>
    <key>KeepAlive</key>
    <true/>
  </dict>
</plist>

When I execute /opt/local/bin/couchdb manually, the process is created, so no problems there. It just seems the launch daemon skips this command.

Any thoughts on how to fix this?

share|improve this question
    
If you change the StandardOutPath and StandardErrorPath to rel files do they show anything? –  Mark Aug 26 '10 at 9:35
    
I'm not quite sure what you mean by 'show anything'. Anyway I've looked at other plist files and they have the same values, so I don't think that's the problem. –  Peter Kruithof Aug 26 '10 at 14:41
    
"However this doesn't work" What do you get instead? Does launchctl exit like everything went fine, or you have an error? Does launchctl list show the daemon? –  zneak Aug 26 '10 at 18:48
add comment

2 Answers 2

up vote 4 down vote accepted

Try the following (one-line command, not two as diplayed !) :

sudo chown -R couchdb:couchdb /opt/local/var/lib/couchdb/ /opt/local/var/log/couchdb/ /opt/local/etc/couchdb/

The reboot.

If it doesn't work, what version of MacPorts and CouchDB do you have ?

share|improve this answer
1  
why rebooting? a sudo launchctl unload -w /Library/LaunchDaemons/org.apache.couchdb.plist && sudo launchctl load -w /Library/LaunchDaemons/org.apache.couchdb.plist will do fine –  Carmine Paolino Aug 28 '10 at 10:30
    
Was too lazy :P –  Studer Aug 28 '10 at 12:57
    
Worked like a charm, thank you! –  Peter Kruithof Aug 29 '10 at 9:13
add comment

I'm not specifically familiar with CouchDB, but I see a couple of potential problems with your .plist file: first, the HOME value being set is weird -- it should be a specific folder path (i.e. wherever you put the couchdb user's home folder), not ~. Second, I suspect you also need to set the PATH environment variable so CouchDB can find the other optional programs you've installed. So that section of the .plist should look something like this:

<key>EnvironmentVariables</key>
<dict>
    <key>HOME</key>
    <string>/usr/local/var/lib/couchdb</string>
    <key>PATH</key>
    <string>/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/opt/local/bin:/opt/local/sbin</string>
</dict>

(Note: the above values are guesses based on a little googling -- you may need to adjust them to where your CouchDB user's home is and/or where your add-on binaries folders are.) To load the changed .plist file, use:

sudo launchctl unload /Library/LaunchDaemons/org.apache.couchdb.plist
sudo launchctl load /Library/LaunchDaemons/org.apache.couchdb.plist

If that doesn't solve the problem, there are a couple of places to look for more info about what's going wrong: first, take a look at the system log (/var/log/system.log), either with the Console utility or a command line tool; it'll have any errors that launchd ran into while trying to process the .plist file or start CouchDB. Second, follow Mark's suggestion about changing StandardOutPath and StandardErrorPath to real files, and looking at what shows up there. This isn't needed if everything's configured properly, but can be very useful for finding out what's wrong when there's a problem (and you can switch them back to /dev/null after the problem has been solved).

share|improve this answer
    
+1 for your detailed approach, however I rather not resort to hacking the plist file (I assume the MacPorts distributed one is right, and will be overwritten again when I upgrade it). Turns out it was a simple rights issue. –  Peter Kruithof Aug 29 '10 at 9:13
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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