0

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?

  • From the `pm2.log` you posted, have you looked at these two log files: `2019-04-24T19:20:24: PM2 log: Application log path : /home/myuser/.pm2/logs` and `2019-04-24T19:20:24: PM2 log: Process dump file : /home/myuser/.pm2/dump.pm2` – Henry Mueller Apr 29 '19 at 04:47
  • Yes, `/home/myuser/.pm2/logs` is a directory containing `err` and `out` logs for my app and `pm2-logrotate`. The `err` logs are empty. The `out` log for my app has no errors and the `out` log for `pm2-logrotate` is shown above. `/home/myuser/.pm2/dump.pm2` contains just `[]`. – nCMr0l6OubNHphE1X8ya Apr 29 '19 at 12:16
  • Have you found a solution to this? – O'tkir Xo'jayev Jul 14 '22 at 12:00
  • I have it going off once a month – O'tkir Xo'jayev Jul 14 '22 at 12:00

1 Answers1

2

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.