Skip to content

Instantly share code, notes, and snippets.

@eddywashere
Last active August 29, 2015 14:02
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eddywashere/1d446b9842bef51e665a to your computer and use it in GitHub Desktop.
Save eddywashere/1d446b9842bef51e665a to your computer and use it in GitHub Desktop.
Run mongod with some decent settings on startup

Create the mongod.conf and insert the config content.

sudo vim /usr/local/var/mongodb/mongod.conf

Grab the path to mongod. which mongod

Create the org.mongo.mongod.plist file and insert the plist content and update the path to mongod.

sudo vim /Library/LaunchDaemons/org.mongo.mongod.plist

Assign the right permissions to it and load it.

sudo chown root:wheel /Library/LaunchDaemons/org.mongo.mongod.plist
sudo launchctl load /Library/LaunchDaemons/org.mongo.mongod.plist

Done.

# Location of MongoDB databases
dbpath = /usr/local/var/mongodb
# Location of log files
logpath = /usr/local/var/log/mongodb/mongo.log
# Only accept local connections
bind_ip = localhost
# Enable journaling
journal = true
# Enable REST
rest = true
# Enable smaller default file sizes
# (saves space on development servers)
smallfiles = true
<?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.mongodb.mongod</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/mongodb/bin/mongod</string>
<string>run</string>
<string>--config</string>
<string>/usr/local/var/mongodb/mongod.conf</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
<key>WorkingDirectory</key>
<string>/usr/local/mongodb</string>
<key>StandardErrorPath</key>
<string>/usr/local/var/log/mongodb/output.log</string>
<key>StandardOutPath</key>
<string>/usr/local/var/log/mongodb/output.log</string>
</dict>
</plist>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment