Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have successfully installed couchdb via homebrew:

% brew install couchdb

...and invoked mutiple instances as directed here:

% OLD=/usr/local
% NEW=/tmp/couchdb

% mkdir -p $NEW/etc/couchdb/
% mkdir -p $NEW/var/{lib,log,run}/couchdb/

% cp $OLD/etc/couchdb/local.ini $NEW/etc/couchdb/

local.ini changes:

[couchdb]
database_dir = /tmp/couchdb/var/lib/couchdb
view_index_dir = /tmp/couchdb/var/lib/couchdb
uri_file = /tmp/couchdb/var/run/couchdb/couch.uri

[httpd]
port = 5985
bind_address = 0.0.0.0

[log]
file = /tmp/couchdb/var/log/couchdb/couch.log

... and startup the startup command:

% couchdb -i -a /tmp/couchdb/etc/couchdb/local.ini

Now that I have this working, how can I start up each instance on boot, and if I wanted to kill an instance (preferred by name or some known identifier), how might selectively do that? I'm running OSX Mountain Lion 10.8.3 (with Xcode command line tools) in case that helps.

share|improve this question

1 Answer 1

The OS X way to start things at boot is launchd, specifically a LaunchDaemon. For a complete understanding, it's worthwhile to read the Apple documentation on launchd; also, there are many questions and answers here to help you.

The short version is, you'll need a file, eg /Library/LaunchDaemons/org.inator.couchdb that looks something like:

<?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>org.inator.couchdb</string>
    <key>ProgramArguments</key>
    <array>
        <string>/usr/local/couchdb</string>
        <string>-i</string>
        <string>-a</string>
        <string>/tmp/couchdb/etc/couchdb/local.ini</string>
    </array>
    <key>OnDemand</key>
    <false/>
    <key>KeepAlive</key>
    <true/>
</dict>
</plist>

Note that this will run as root; if you want it to run as a particular user, you'll need to use sudo (eg sudo -u inator /usr/local/couchdb …).

To start and the job manually, you can load and unload it from launchd using launchctl, eg:

launchctl load /Library/LaunchDaemons/org.inator.couchdb
launchctl unload /Library/LaunchDaemons/org.inator.couchdb

If you want another instance, just create a new file in /Library/LaunchDaemons with a different filename (and a matching Label).

share|improve this answer

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.