以下是我的json文件。文件名( pm2-ecosystem.json )
{
"apps" : [{
"name" : "Performance",
"script" : "server.js",
"watch" : false,
"exec_mode" : "cluster_mode",
"instances" : 4,
"max_memory_restart" : "500M",
"merge_logs": true,
"env": {
"NODE_ENV": "development"
},
"env_production" : {
"NODE_ENV": "production"
}
}]
}
我正在通过package.json中的以下脚本重新启动它
"scripts": {
"build-prod": "pm2 restart pm2-ecosystem.json --env production"
},
我遇到这样的错误:
2019-03-19T02:49:21:PM2错误:错误:生成/ usr / local / bin / node ENOENT PM2 |在_errnoException(util.js:1024:11)PM2
|在Process.ChildProcess._handle.onexit (内部/child_process.js:192:19)PM2 |在onErrorNT (internal / child_process.js:374:16)PM2 |在 _combinedTickCallback(内部/进程/next_tick.js:138:11)PM2 |在process._tickDomainCallback (内部/进程/next_tick.js:218:9)PM2 | 2019-03-19T02:49:21:PM2日志:应用名称:标枪后端ID:56 PM2已断开连接| 2019-03-19T02:49:43:PM2日志:应用 [标枪后端:56]在-cluster模式下启动-PM2 | 2019-03-19T02:49:43:PM2错误:错误:产生/ usr / local / bin / node ENOENT PM2 |在_errnoException(util.js:1024:11)PM2
|在Process.ChildProcess._handle.onexit (内部/child_process.js:192:19)PM2 |在onErrorNT (internal / child_process.js:374:16)PM2 |在 _combinedTickCallback(内部/进程/next_tick.js:138:11)PM2 |在process._tickDomainCallback (内部/进程/next_tick.js:218:9)PM2 | 2019-03-19T02:49:43:PM2日志:应用名称:标枪后端ID:56 断开连接
答案 0 :(得分:1)
您可以尝试以下代码,
pm2.connect(function() {
pm2.start({
"script" : /* Path to your starting file */,
"exec_mode" : "cluster",
"pmx" : false
}, function(err, apps) {
pm2.disconnect();
});
})