tybro0103
tybro0103

Reputation: 49693

Run MongoDB server as a service (detached from terminal)?

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.

Upvotes: 31

Views: 31795

Answers (2)

Chris Fulstow
Chris Fulstow

Reputation: 41872

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.

Upvotes: 0

Emily
Emily

Reputation: 18193

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.

Upvotes: 64

Related Questions