在pm2之前运行node.js,但通常会重新启动:通过信号[SIGINT]以代码[0]退出 [英] run node.js by pm2,but often restart:exited with code [0] via signal [SIGINT]
问题描述
我正在尝试在系统上运行node.js,但是遇到了这个问题:
I am trying to run node.js on my system but running into this problem:
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,但是由于以下原因,它经常重新启动:exited with code [0] via signal [SIGINT]
.为什么会这样?
I run node.js using pm2, but it often restarts because of the following: exited with code [0] via signal [SIGINT]
. Why is this?
一些其他信息:
~$ 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时,我也遇到了类似的错误消息:
I had similar error message when running pm2 with a 3rd-party utility:
PM2 | App [Utility:2] exited with code [1] via signal [SIGINT]
PM2一直在重新启动该实用程序.
PM2 just kept restarting the utility.
我尝试在没有pm2的情况下运行该实用程序,但实际上并没有退出.我想知道为什么pm2决定重新启动该实用程序. (尚无答案,尽管从日志来看,这是由于SIGINT造成的)
And I tried running the utility without pm2, it did not actually exit. I was wondering why pm2 decided to restart the utility. (No answer yet, though from the log, it's due to SIGINT)
我们不希望该实用程序继续重启.
We don't want the utility to keep restarting.
发现的结果是,如果我们使用pm2来以群集模式(而不是派生模式)运行该实用程序(请参见下面的exec_mode: 'cluster_mode'
),则该实用程序将在不重启的情况下正常工作.
What we found is, if we use pm2 to run the utility in cluster mode instead of fork mode(see exec_mode: 'cluster_mode'
below), the utility works without keeping restarting.
pm2.utility.config.js
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.
Note: my pm2 is of version 3.4.0.
这篇关于在pm2之前运行node.js,但通常会重新启动:通过信号[SIGINT]以代码[0]退出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!