Mar
1st
2010
Mon
1st
2010
Auto-starting mongodb at boot time on OSX
This really goes for starting any daemon at boot, but here’s a specific example for mongodb. Make a file and call it something like “org.mongodb.start.plist”:
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.mongodb.start</string>
<key>ProgramArguments</key>
<array>
<string>/path/to/mongodb/bin/mongod</string>
<string>-f</string>
<string>/etc/mongodb.conf</string>
</array>
<key>RunAtLoad</key>
<true></true>
<key>UserName</key>
<string>fields</string>
</dict>
</plist>
Put that file in /Library/LaunchDaemons, and chmod/chown it:
sudo chown root:wheel /Library/LaunchDaemons/org.mongodb.start.plist sudo chmod 644 /Library/LaunchDaemons/org.mongodb.start.plist
It should then start at boot time. Use the launchctl command line to see what went wrong utility if it doesn’t run.
launchctl list | grep mongo launchctl help