pm2 Daemon Dies After a Few Hours

◇◆丶佛笑我妖孽 提交于 2021-01-29 18:32:03

问题


I have a Node.js/Express app that implements a set of REST APIs and I'm attempting to use pm2 to manage its deployment. The app starts fine (using pm2 start ecosystem.config.js) and remains available for a few hours, but the pm2 daemon always dies eventually without any errors in the logs.

A few notes:

  • I'm running in a CentOS 7 shared hosting environment.
  • The /var/log directory is empty and journalctl doesn't return any entries.
  • I've verified that the system isn't rebooting.
  • The only pm2 module I have installed is pm2-logrotate.
  • I'm trapping and logging SIGINT, SIGTERM, SIGQUIT, and SIGABRT signals, but that logic never seems to get hit (it does if I run pm2 stop).
  • If I run pm2 list it just restarts the daemon and shows an empty app list.

Here's my ecosystem.config.js:

module.exports = {
  apps: [
    {
      kill_timeout: 60000,
      listen_timeout: 10000,
      log: 'logs/my-app.log',
      name: 'my-app',
      script: 'dist/index.js',
      wait_ready: true,

      instances: 1,
      autorestart: true,
      watch: false,
      max_memory_restart: '1G',
      env: {
        NODE_ENV: 'development'
      },
      env_production: {
        NODE_ENV: 'production'
      }
    }
  ]
};

Here's pm2.log:

2019-04-24T19:20:24: PM2 log: ===============================================================================
2019-04-24T19:20:24: PM2 log: --- New PM2 Daemon started ----------------------------------------------------
2019-04-24T19:20:24: PM2 log: Time                 : Wed Apr 24 2019 19:20:24 GMT-0700 (Mountain Standard Time)
2019-04-24T19:20:24: PM2 log: PM2 version          : 3.5.0
2019-04-24T19:20:24: PM2 log: Node.js version      : 10.5.0
2019-04-24T19:20:24: PM2 log: Current arch         : x64
2019-04-24T19:20:24: PM2 log: PM2 home             : /home/myuser/.pm2
2019-04-24T19:20:24: PM2 log: PM2 PID file         : /home/myuser/.pm2/pm2.pid
2019-04-24T19:20:24: PM2 log: RPC socket file      : /home/myuser/.pm2/rpc.sock
2019-04-24T19:20:24: PM2 log: BUS socket file      : /home/myuser/.pm2/pub.sock
2019-04-24T19:20:24: PM2 log: Application log path : /home/myuser/.pm2/logs
2019-04-24T19:20:24: PM2 log: Process dump file    : /home/myuser/.pm2/dump.pm2
2019-04-24T19:20:24: PM2 log: Concurrent actions   : 2
2019-04-24T19:20:24: PM2 log: SIGTERM timeout      : 1600
2019-04-24T19:20:24: PM2 log: ===============================================================================
2019-04-24T19:20:24: PM2 log: App [pm2-logrotate:0] starting in -fork mode-
2019-04-24T19:20:24: PM2 log: App [pm2-logrotate:0] online
2019-04-24T19:20:24: PM2 log: App [my-app:1] starting in -fork mode-
2019-04-24T19:20:28: PM2 log: App [my-app:1] online

Here's pm2-logrotate-out.log:

"/home/myuser/.pm2/logs/my-app-out-1__2019-04-25_00-00-00.log" has been created
"/home/myuser/my-app/logs/my-app-1__2019-04-25_00-00-00.log" has been created

Any idea what's causing this issue or how I can debug it further?


回答1:


It turns out that this was caused by resource limiting imposed by my hosting provider. I'm still confused about why nothing was logged to indicate what happened, but I'm marking this as answered since I've found the root cause.



来源:https://stackoverflow.com/questions/55896215/pm2-daemon-dies-after-a-few-hours

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!