简体   繁体   中英

Nodejs pm2 is always restarting when I reboot Ubuntu

I have an express nodejs server running in Ubuntu LTS with pm2. The server runs fine, but when I restart Ubuntu, the server is always rebooting.

I use an ecossystem.config like this:

module.exports = {
  apps : [{
    name: 'gTimeTracking',
    script: 'index.js',
    args: 'one two',
    instances: 1,
    autorestart: true,
    watch: true,
    max_memory_restart: '1G',
    env: {
      NODE_ENV: 'development'
    },
    env_production: {
      NODE_ENV: 'production'
    }
  }]
};

I started the server with this command:

pm2 start ecosystem.config.js --env production

And with pm2 save

and I have this infinite error on Ubuntu reboot

0|gTimeTracking  | Server running since: Mon Jul 01 2019 09:36:43 GMT+0200 (CEST)
PM2              | Change detected on path logs/logger-01-07-2019-09.log for app gTimeTracking - restarting
PM2              | Stopping app:gTimeTracking id:0
PM2              | App [gTimeTracking:0] exited with code [0] via signal [SIGINT]
PM2              | pid=16255 msg=process killed
PM2              | App [gTimeTracking:0] starting in -fork mode-
PM2              | App [gTimeTracking:0] online
0|gTimeTracking  | Server running since: Mon Jul 01 2019 09:36:44 GMT+0200 (CEST)
PM2              | Change detected on path logs/logger-01-07-2019-09.log for app gTimeTracking - restarting
PM2              | Stopping app:gTimeTracking id:0
PM2              | App [gTimeTracking:0] exited with code [0] via signal [SIGINT]
PM2              | pid=16274 msg=process killed
PM2              | App [gTimeTracking:0] starting in -fork mode-
PM2              | App [gTimeTracking:0] online

Last time I had this problem I had to reinstall many times pm2 to relaunch the server, but now this method doesn't works and isn't an stable solution

What could be wrong?

I had to use pm2 cleardump for solve the problem with pm2 delete all and pm2 kill it didn't works for me. (I didn't have to change anything about the loggers path)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM