如何使用 PM2 运行 MongoDB [英] How to run MongoDB using PM2

查看:75
本文介绍了如何使用 PM2 运行 MongoDB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用 PM2 运行 MongoDB?我正在使用 Linux VPS (CentOS),我尝试这样做:

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

pm2 mongod

^ 可行,但问题是我需要绑定 IP 和 DBPath 名称

^ 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

^ 但由于 PM2 标志,这不起作用.那么我如何使用 PM2 运行它,或者至少让它在我关闭终端时不会关闭

^ 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

推荐答案

您可以创建一个运行命令的 SH 文件,然后运行该 SH 文件.

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

另一种方法是这样;

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

这篇关于如何使用 PM2 运行 MongoDB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆