Dejan Toteff
Dejan Toteff

Reputation: 2197

How to make Mongodb autorun in Node.js

I am on Win7. I run MongoDB with command: >mongod --dbpath=C:/mongo/ What worries me that the service require the cmd window to be always open. I wonder is there a way to make Node.js(Express) run this command automatically?

Upvotes: 0

Views: 369

Answers (1)

David Losert
David Losert

Reputation: 4802

As for development, I don't see the problem running MongoDB in a CMD. If it bothers you that much, you could just run it as a Service as described on the official page here. On a production System, you should do this anyways.

You could also try using child_process to startup the Database - but thats not a good Idea as it tangles your app with your database, which is pretty ugly (and will make it hard for other developers on your project)

Upvotes: 1

Related Questions