【发布时间】:2022-09-26 02:39:04
【问题描述】:
是否有用于在特定目录中运行 pm2 start npm -- start 的 CLI 标记?我环顾四周,但找不到答案。
另一方面,当我运行 pm2没有npm,我可以指定要在哪个目录运行pm2。例如:
pm2 start /opt/www/myapp/index.js
有没有办法在pm2 start npm -- start 命令中添加路径标签?
是否有用于在特定目录中运行 pm2 start npm -- start 的 CLI 标记?我环顾四周,但找不到答案。
另一方面,当我运行 pm2没有npm,我可以指定要在哪个目录运行pm2。例如:
pm2 start /opt/www/myapp/index.js
有没有办法在pm2 start npm -- start 命令中添加路径标签?
你可以使用这样的东西:
cd /directory/of/my/app ; pm2 start npm -- start
您还可以编写一个生态系统文件来参数您的应用程序:
{
"apps": [
{
"name": "my-app",
"cwd": "/path/to/app",
"script": "npm",
"args": "start"
}
]
}
要生成一个空的生态系统文件:
pm2 init simple
这将生成一个名为 ecosystem.config.js 的文件,您可以重命名该文件。
然后开始应用:
pm2 start ecosystem.config.js
生态系统文档:https://pm2.keymetrics.io/docs/usage/application-declaration/
【讨论】: