Issue
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
Solution
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"
Answered By - Felix Isaac Answer Checked By - Gilberto Lyons (PHPFixing Admin)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.