PM2 在进程崩溃后启动一个新的守护进程并且不重新启动进程
PM2 starts a new daemon after a process crashes and doesn't restart the processes
我的应用 "prod" 未在 SIGINT 上恢复。
相反,PM2 会使所有其他应用程序崩溃并重新启动守护程序。
如果我关闭其他应用程序,它会正常工作:它们会自动重启。
我的日志如下所示:
(process:3626): GLib-GObject-CRITICAL **: g_object_unref: assertion 'G_IS_OBJECT (object)' failed
(process:3626): GLib-GObject-CRITICAL **: g_object_unref: assertion 'G_IS_OBJECT (object)' failed
(process:3626): GLib-GObject-CRITICAL **: g_object_unref: assertion 'G_IS_OBJECT (object)' failed
(process:3626): GLib-GObject-CRITICAL **: g_object_unref: assertion 'G_IS_OBJECT (object)' failed
(process:3626): GLib-GObject-CRITICAL **: g_object_unref: assertion 'G_IS_OBJECT (object)' failed
(process:3626): GLib-GObject-CRITICAL **: g_object_unref: assertion 'G_IS_OBJECT (object)' failed
(process:3626): GLib-GObject-CRITICAL **: g_object_unref: assertion 'G_IS_OBJECT (object)' failed
(process:3626): GLib-GObject-CRITICAL **: g_object_unref: assertion 'G_IS_OBJECT (object)' failed
2020-03-02T21:02:37: PM2 log: App name:prod id:4 disconnected
2020-03-02T21:02:37: PM2 log: App [prod:4] exited with code [0] via signal [SIGSEGV]
2020-03-02T21:02:37: PM2 log: App [prod:4] starting in -cluster mode-
2020-03-02T21:02:37: PM2 log: App [prod:4] online
2020-03-02T21:02:45: PM2 log: ===============================================================================
2020-03-02T21:02:45: PM2 log: --- New PM2 Daemon started ----------------------------------------------------
2020-03-02T21:02:45: PM2 log: Time : Mon Mar 02 2020 21:02:45 GMT+0100 (Central European Standard Time)
2020-03-02T21:02:45: PM2 log: PM2 version : 4.2.0
2020-03-02T21:02:45: PM2 log: Node.js version : 11.10.0
2020-03-02T21:02:45: PM2 log: Current arch : x64
2020-03-02T21:02:45: PM2 log: PM2 home : /home/ubuntu/.pm2
2020-03-02T21:02:45: PM2 log: PM2 PID file : /home/ubuntu/.pm2/pm2.pid
2020-03-02T21:02:45: PM2 log: RPC socket file : /home/ubuntu/.pm2/rpc.sock
2020-03-02T21:02:45: PM2 log: BUS socket file : /home/ubuntu/.pm2/pub.sock
2020-03-02T21:02:45: PM2 log: Application log path : /home/ubuntu/.pm2/logs
2020-03-02T21:02:45: PM2 log: Worker Interval : 30000
2020-03-02T21:02:45: PM2 log: Process dump file : /home/ubuntu/.pm2/dump.pm2
2020-03-02T21:02:45: PM2 log: Concurrent actions : 2
2020-03-02T21:02:45: PM2 log: SIGTERM timeout : 1600
2020-03-02T21:02:45: PM2 log: ===============================================================================
2020-03-02T21:02:45: PM2 log: App [pm2-health:0] starting in -fork mode-
2020-03-02T21:02:45: PM2 log: App [pm2-health:0] online
这是我的 "prod"
生态系统文件
module.exports = {
apps : [{
name: 'prod',
script: 'index.js',
args: ["--color"],
instances: 4,
autorestart: true,
out_file: "logs/prod.log",
node_args: "--max-old-space-size=2048"
}]
};
我的显示器看起来像:
│ id │ name │ namespace │ version │ mode │ pid │ uptime │ ↺ │ status │ cpu │ mem │ user │ watching │
├─────┼─────────────┼─────────────┼─────────┼─────────┼──────────┼────────┼──────┼───────────┼──────────┼──────────┼──────────┼──────────┤
│ 6 │ beta │ default │ 1.0.0 │ fork │ 4031 │ 5m │ 0 │ online │ 0% │ 154.8mb │ ubuntu │ enabled │
│ 1 │ prod │ default │ 1.0.0 │ cluster │ 3619 │ 5m │ 0 │ online │ 75% │ 372.1mb │ ubuntu │ disabled │
│ 2 │ prod │ default │ 1.0.0 │ cluster │ 3626 │ 5m │ 0 │ online │ 5% │ 361.4mb │ ubuntu │ disabled │
│ 3 │ prod │ default │ 1.0.0 │ cluster │ 3635 │ 5m │ 0 │ online │ 0% │ 297.1mb │ ubuntu │ disabled │
│ 4 │ prod │ default │ 1.0.0 │ cluster │ 3644 │ 5m │ 0 │ online │ 5% │ 510.0mb │ ubuntu │ disabled │
│ 5 │ sandbox │ default │ 1.0.0 │ cluster │ 3970 │ 5m │ 0 │ online │ 0% │ 132.2mb │ ubuntu │ enabled │
└─────┴─────────────┴─────────────┴─────────┴─────────┴──────────┴────────┴──────┴───────────┴──────────┴──────────┴──────────┴──────────┘
请帮忙。这是一个大问题,因为它使我的服务器无法自动恢复。
我更新到最新版本的 PM2,但由于它触发了上述问题而降级。然而,它并没有改变任何东西
这个问题已经通过将 PM2 放入 docker 中得到解决。现在运行很顺利。
检查 Docker 集成:https://pm2.keymetrics.io/docs/usage/docker-pm2-nodejs/
我的应用 "prod" 未在 SIGINT 上恢复。 相反,PM2 会使所有其他应用程序崩溃并重新启动守护程序。
如果我关闭其他应用程序,它会正常工作:它们会自动重启。
我的日志如下所示:
(process:3626): GLib-GObject-CRITICAL **: g_object_unref: assertion 'G_IS_OBJECT (object)' failed
(process:3626): GLib-GObject-CRITICAL **: g_object_unref: assertion 'G_IS_OBJECT (object)' failed
(process:3626): GLib-GObject-CRITICAL **: g_object_unref: assertion 'G_IS_OBJECT (object)' failed
(process:3626): GLib-GObject-CRITICAL **: g_object_unref: assertion 'G_IS_OBJECT (object)' failed
(process:3626): GLib-GObject-CRITICAL **: g_object_unref: assertion 'G_IS_OBJECT (object)' failed
(process:3626): GLib-GObject-CRITICAL **: g_object_unref: assertion 'G_IS_OBJECT (object)' failed
(process:3626): GLib-GObject-CRITICAL **: g_object_unref: assertion 'G_IS_OBJECT (object)' failed
(process:3626): GLib-GObject-CRITICAL **: g_object_unref: assertion 'G_IS_OBJECT (object)' failed
2020-03-02T21:02:37: PM2 log: App name:prod id:4 disconnected
2020-03-02T21:02:37: PM2 log: App [prod:4] exited with code [0] via signal [SIGSEGV]
2020-03-02T21:02:37: PM2 log: App [prod:4] starting in -cluster mode-
2020-03-02T21:02:37: PM2 log: App [prod:4] online
2020-03-02T21:02:45: PM2 log: ===============================================================================
2020-03-02T21:02:45: PM2 log: --- New PM2 Daemon started ----------------------------------------------------
2020-03-02T21:02:45: PM2 log: Time : Mon Mar 02 2020 21:02:45 GMT+0100 (Central European Standard Time)
2020-03-02T21:02:45: PM2 log: PM2 version : 4.2.0
2020-03-02T21:02:45: PM2 log: Node.js version : 11.10.0
2020-03-02T21:02:45: PM2 log: Current arch : x64
2020-03-02T21:02:45: PM2 log: PM2 home : /home/ubuntu/.pm2
2020-03-02T21:02:45: PM2 log: PM2 PID file : /home/ubuntu/.pm2/pm2.pid
2020-03-02T21:02:45: PM2 log: RPC socket file : /home/ubuntu/.pm2/rpc.sock
2020-03-02T21:02:45: PM2 log: BUS socket file : /home/ubuntu/.pm2/pub.sock
2020-03-02T21:02:45: PM2 log: Application log path : /home/ubuntu/.pm2/logs
2020-03-02T21:02:45: PM2 log: Worker Interval : 30000
2020-03-02T21:02:45: PM2 log: Process dump file : /home/ubuntu/.pm2/dump.pm2
2020-03-02T21:02:45: PM2 log: Concurrent actions : 2
2020-03-02T21:02:45: PM2 log: SIGTERM timeout : 1600
2020-03-02T21:02:45: PM2 log: ===============================================================================
2020-03-02T21:02:45: PM2 log: App [pm2-health:0] starting in -fork mode-
2020-03-02T21:02:45: PM2 log: App [pm2-health:0] online
这是我的 "prod"
生态系统文件module.exports = {
apps : [{
name: 'prod',
script: 'index.js',
args: ["--color"],
instances: 4,
autorestart: true,
out_file: "logs/prod.log",
node_args: "--max-old-space-size=2048"
}]
};
我的显示器看起来像:
│ id │ name │ namespace │ version │ mode │ pid │ uptime │ ↺ │ status │ cpu │ mem │ user │ watching │
├─────┼─────────────┼─────────────┼─────────┼─────────┼──────────┼────────┼──────┼───────────┼──────────┼──────────┼──────────┼──────────┤
│ 6 │ beta │ default │ 1.0.0 │ fork │ 4031 │ 5m │ 0 │ online │ 0% │ 154.8mb │ ubuntu │ enabled │
│ 1 │ prod │ default │ 1.0.0 │ cluster │ 3619 │ 5m │ 0 │ online │ 75% │ 372.1mb │ ubuntu │ disabled │
│ 2 │ prod │ default │ 1.0.0 │ cluster │ 3626 │ 5m │ 0 │ online │ 5% │ 361.4mb │ ubuntu │ disabled │
│ 3 │ prod │ default │ 1.0.0 │ cluster │ 3635 │ 5m │ 0 │ online │ 0% │ 297.1mb │ ubuntu │ disabled │
│ 4 │ prod │ default │ 1.0.0 │ cluster │ 3644 │ 5m │ 0 │ online │ 5% │ 510.0mb │ ubuntu │ disabled │
│ 5 │ sandbox │ default │ 1.0.0 │ cluster │ 3970 │ 5m │ 0 │ online │ 0% │ 132.2mb │ ubuntu │ enabled │
└─────┴─────────────┴─────────────┴─────────┴─────────┴──────────┴────────┴──────┴───────────┴──────────┴──────────┴──────────┴──────────┘
请帮忙。这是一个大问题,因为它使我的服务器无法自动恢复。
我更新到最新版本的 PM2,但由于它触发了上述问题而降级。然而,它并没有改变任何东西
这个问题已经通过将 PM2 放入 docker 中得到解决。现在运行很顺利。 检查 Docker 集成:https://pm2.keymetrics.io/docs/usage/docker-pm2-nodejs/