Run MongoDB server as a service (detached from terminal)?
Question
When I start the MongoDB server (mongod) from terminal it keeps that tab open. How do I go about running it as a service?
I'm on OSX Lion.
I like how the rails server script has a -d option to detach it from terminal.
Solution
This is built into mongod
, much like it is in the rails server. Instead of -d
you'll need to use --fork
and you'll probably want to specify --logpath /path-to/logfile --logappend
as well, so that your output will be logged and will keep any previous logs.
See the docs on starting and stopping Mongo for more information.
OTHER TIPS
To set up MongoDB to run as a background service, check out the mongo-installer package for OS X 10.5+ or the MongoDB-OSX-Launchctl scripts.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow