[英]Unable to start PM2 application with json file
I am facing a peculiar issue.我面临一个特殊的问题。 I am trying to start my application with pm2.
我正在尝试使用 pm2 启动我的应用程序。 Without the json file, it works perfectly fine, but when I add a json file and try to start it, it does not hit my application in the first start, but works well if I stop and start the instance again.Also, when the instance is first started if I do pm2 list, the PID number keeps changing continually.
如果没有 json 文件,它可以正常工作,但是当我添加 json 文件并尝试启动它时,它不会在第一次启动时命中我的应用程序,但如果我停止并再次启动实例,它会运行良好。另外,当如果我执行 pm2 list,则首先启动实例,PID 号不断变化。 Any help on this please?
请问有什么帮助吗? PM2 json file:
PM2 json 文件:
{
"apps" : [{
"name" : "ABC",
"script" : "./bin/www",
"watch" : true,
"env": {
"NODE_ENV": "development",
"PORT":8443
},
"env_production" : {
"NODE_ENV": "production",
"PORT":4000
},
"error_file" : "err.log",
"out_file" : "out.log",
"merge_logs" : false
}]
}
Command to start the application with pm2 json file: pm2 start sample.json Command to stop the application with pm2 json file: pm2 stop ABC to kill: pm2 kill使用 pm2 启动应用程序的命令 json 文件:pm2 start sample.json 使用 pm2 停止应用程序的命令 json 文件:pm2 stop ABC to kill: pm2 kill
Thanks in advance.提前致谢。
You might try setting your exec_mode
to fork
. 您可以尝试将
exec_mode
设置为fork
。 If I had to guess, it's starting up with a default mode of cluster
and it spins up the number of instances equivalent to the number of processors as detected by the system. 如果我不得不猜测的话,它是从默认的
cluster
模式启动的,它增加了实例数量,该实例数量等于系统检测到的处理器数量。 While this is typically fine for webapps, it's not always suitable for all situations. 虽然这通常对Web应用程序来说不错,但并不总是适合所有情况。
You could also try setting instances
to 1
in cluster
mode 您也可以尝试在
cluster
模式下将instances
设置为1
Your PM2-JSON-File
looks good but how looks like your您的
PM2-JSON-File
看起来不错,但看起来像您的
package.json
....
"scripts": {
"start": "node start -p 8443 /bin/www"
"test": "echo \"Error: no test specified\" && exit 1"
},
.....
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.