How to run MongoDB using PM2

旧街凉风 提交于 2020-12-04 08:53:40

问题


How do I run MongoDB using PM2? I'm using a Linux VPS (CentOS) and I tried doing this:

pm2 mongod

^ and that works but the problem is I need to bind IP and DBPath name

pm2 mongod -dbpath /home/[ommitted]/data/db --bind_ip [ommitted] -auth

^ But that doesn't work because of PM2 flags. So how can I run it using PM2 or at least make it so it doesn't shut down when I close the terminal


回答1:


You can create an SH file that runs the command, then run the SH file.

1. For example, name it "run.sh"
2. Open/edit file
3. Add this to the first line of the file mongod -dbpath /home/[ommitted]/data/db --bind_ip [ommitted] -auth
4. pm2 start run.sh

Another way that you can do is this;

pm2 start "mongod -dbpath /home/[ommitted]/data/db --bind_ip [ommitted] -auth"


来源:https://stackoverflow.com/questions/55303828/how-to-run-mongodb-using-pm2

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