Javascript 通过pm2运行node.js,但经常重新启动:通过信号[SIGINT]退出,代码为[0]
我试图在系统上运行node.js,但遇到以下问题:Javascript 通过pm2运行node.js,但经常重新启动:通过信号[SIGINT]退出,代码为[0],javascript,node.js,pm2,Javascript,Node.js,Pm2,我试图在系统上运行node.js,但遇到以下问题: 2016-06-01 20:46:28: App [app] with id [13] and pid [12633], exited with code [0] via signal [SIGINT] 2016-06-01 20:46:28: Starting execution sequence in -cluster mode- for app name:app id:13 2016-06-01 20:46:28: App name:ap
2016-06-01 20:46:28: App [app] with id [13] and pid [12633], exited with code [0] via signal [SIGINT]
2016-06-01 20:46:28: Starting execution sequence in -cluster mode- for app name:app id:13
2016-06-01 20:46:28: App name:app id:13 online
2016-06-01 20:46:28: App name:app id:4 disconnected
2016-06-01 20:46:28: App [app] with id [4] and pid [47284], exited with code [0] via signal [SIGINT]
2016-06-01 20:46:28: Starting execution sequence in -cluster mode- for app name:app id:4
2016-06-01 20:46:29: App name:app id:4 online
2016-06-01 20:46:44: App name:app id:3 disconnected
2016-06-01 20:46:44: App [app] with id [3] and pid [42456], exited with code [0] via signal [SIGINT]
2016-06-01 20:46:44: Starting execution sequence in -cluster mode- for app name:app id:3
2016-06-01 20:46:44: App name:app id:3 online
2016-06-01 20:46:45: App name:app id:2 disconnected
2016-06-01 20:46:45: App [app] with id [2] and pid [47045], exited with code [0] via signal [SIGINT]
2016-06-01 20:46:45: Starting execution sequence in -cluster mode- for app name:app id:2
2016-06-01 20:46:45: App name:app id:2 online
2016-06-01 20:46:49: App name:app id:6 disconnected
2016-06-01 20:46:49: App [app] with id [6] and pid [47326], exited with code [0] via signal [SIGINT]
2016-06-01 20:46:49: Starting execution sequence in -cluster mode- for app name:app id:6
2016-06-01 20:46:49: App name:app id:6 online
2016-06-01 20:46:49: App name:app id:10 disconnected
2016-06-01 20:46:49: App [app] with id [10] and pid [47291], exited with code [0] via signal [SIGINT]
2016-06-01 20:46:49: Starting execution sequence in -cluster mode- for app name:app id:10
2016-06-01 20:46:49: App name:app id:10 online
2016-06-01 20:48:33: App name:app id:2 disconnected
我使用pm2运行node.js,但由于以下原因,它通常会重新启动:通过信号[SIGINT]
与代码[0]一起退出。为什么会这样
一些补充资料:
~$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/xvda1 40G 9.8G 28G 27% /
none 4.0K 0 4.0K 0% /sys/fs/cgroup
udev 7.9G 4.0K 7.9G 1% /dev
tmpfs 1.6G 380K 1.6G 1% /run
none 5.0M 0 5.0M 0% /run/lock
none 7.9G 0 7.9G 0% /run/shm
none 100M 0 100M 0% /run/user
~$ free -m
total used free shared buffers cached
Mem: 16035 8177 7857 0 174 3672
-/+ buffers/cache: 4331 11704
Swap: 0 0 0
~$ node -v
v5.1.1
~$ npm -v
3.3.12
我遇到了同样的问题,pm2每秒钟重新启动一次,正常运行时间为0秒。我找到了一份工作:
pm2启动bin/www-i 0
//这将启动集群和主应用程序pm2停止0
//这将允许群集保持运行在使用第三方实用程序运行pm2时,我收到了类似的错误消息:
PM2 | App [Utility:2] exited with code [1] via signal [SIGINT]
PM2只是一直在重启公用事业
我试着在没有pm2的情况下运行这个实用程序,它实际上并没有退出。我想知道为什么pm2决定重新启动公用事业。(目前还没有答案,不过从日志来看,这是由于SIGINT)
我们不希望该实用程序继续重新启动
解决方案/变通办法
我们发现,如果我们使用pm2在集群模式下运行该实用程序,而不是在fork模式下运行该实用程序(请参见下面的exec\u模式:“集群模式”
),该实用程序将不会继续重新启动
pm2.utility.config.js
const pm2Config = {
apps: [
{
name: 'Utility',
script: './3rd/utility.js',
exec_mode: 'cluster_mode',
instances: 1,
},
],
}
module.exports = pm2Config
然后运行pm2:
pm2 start pm2.utility.config.js
注意:我的pm2是3.4.0版。请检查
应用程序监听(portid,“私有ip”)
行在我的例子中,这是注释的,当我取消注释它的工作时如果您在集群模式下运行pm2,并试图创建多个实例,并且得到您报告的错误,请检查您的机器有多少cpu核心。因为如果您的cpu只有一个内核,并且您尝试使用多个实例运行pm2,则会出现错误,但是分叉模式不会给您错误。没有pm2,您的代码运行正常吗?添加集群对我来说很有效,我想有些时候我们可能需要在启动pm2之前运行pm2 delete all一次。你可以使用以下命令检查ubuntu中的cpu核心:grep-c^processor/proc/cpuinfoIn这行是哪个文件?我在哪里能找到它?