[英]How to run multiple app using PM2?
I want to run my angular4 app using PM2 it will run but when I am close the terminal it will stop. 我想使用PM2运行我的angular4应用,它将运行,但是当我关闭终端时 ,它将停止。
On this server already run one application, it is working properly, but in my app it will work when I am open the terminal, otherwise it will stop 在这台服务器上已经运行了一个应用程序,它可以正常运行, 但是在我的应用程序中,当我打开终端时它将运行,否则它将停止
pm2 start server.js pm2启动server.js
I am using this command to run my app but when I am Close the Terminal immediately it will stop, so how can I run this app Forever using PM2. 我正在使用此命令运行我的应用程序,但是当我立即关闭终端时,它将停止,因此如何使用PM2永久运行此应用程序。
If you are using PM2 properly, your applications should not be turning off after terminal exit. 如果您正确使用PM2,则退出终端后不应关闭应用程序。 It is very likely that your application is failing.
您的应用程序很可能失败。 Run
pm2 logs
to diagnose. 运行
pm2 logs
。
You can specify multiple applications in a process.json
file like this: 您可以在
process.json
文件中指定多个应用程序,如下所示:
{
"apps" : [{
"name" : "worker",
"script" : "./worker.js",
"watch" : true,
"env": {
"NODE_ENV": "development"
},
"env_production" : {
"NODE_ENV": "production"
}
},{
"name" : "api-app",
"script" : "./api.js",
"instances" : 4,
"exec_mode" : "cluster"
}]
}
Started like this: 像这样开始:
pm2 start process.json
And can monitor/view your applications by running pm2 monit
or pm2 ls
并且可以通过运行
pm2 monit
或pm2 ls
监视/查看您的应用程序
Everything is fine just run below command from ROOT 一切都很好,只需在ROOT的命令下运行
1) first go to your Project Directory and run below from from ROOT. 1)首先转到您的项目目录,然后从ROOT下运行。
pm2 start server.js
it will work fine. 它将正常工作。
If you are running the same script multiple times, with different parameters for instance, just give them different names. 如果您多次运行相同的脚本(例如,使用不同的参数),则给它们指定不同的名称。
ie 即
PM2 Start Engage.js --name Warp1 PM2启动Engage.js --name Warp1
PM2 Start Engage.js --name Warp2 PM2启动Engage.js --name Warp2
PM2 Start Engage.js --name Impulse PM2启动Engage.js --name脉冲
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.