Running mongodb forever using forever in windows

守給你的承諾、 提交于 2019-12-25 13:09:18

问题


I am trying to run MongoDB server forever locally on Windows 10. And for that I'm using forever server.js which throws an error i.e, Forever is not installed.

I did npm install. But then too showing the same error. I have followed this guide, but it's for Ubuntu. I am using Windows 10.

I need something like if I close the server cmd also, it should keep running.


回答1:


In Windows, you can use the mongod command to register Mongo as a service

mongod --directoryperdb --dbpath "C:\Program Files\MongoDB\Server\3.4\data\db" --logpath "C:\Program Files\MongoDB\Server\3.4\log\mongo.log" --logappend --rest --install

  1. Open the cmd(command prompt) as administrator
  2. run the above command
  3. open services and search for mongo service
  4. If it is not running already, click start to start the service



回答2:


You need to install mongo as a service. To do so,

  1. Open cmd in administrator mode.
  2. Create two directories to store data and logs

mkdir c:\data\db

mkdir c:\data\log

  1. Create a configuration file. The file must set systemLog.path. Include additional configuration options as appropriate.For example, create a file at C:\Program Files\MongoDB\Server\3.6\mongod.cfg that specifies both systemLog.path and storage.dbPath like this:

systemLog:

destination: file

path: c:\data\log\mongod.log

storage:

dbPath: c:\data\db

  1. install mongo service, run the following command:

    mongod.exe --config "C:\Program Files\MongoDB\Server\3.4\mongod.cfg" --install

  2. Start service using: >net start mongodb

    1. To stop service use : >net stop mongodb

You can refer official documents here



来源:https://stackoverflow.com/questions/47654689/running-mongodb-forever-using-forever-in-windows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!