skip to Main Content

I have a NodeJs+Express+Mongodb app and I’m trying to run it on my vps.
I do :

pm2 start server

[PM2] Applying action restartProcessId on app [server](ids: [ 1 ])
[PM2] [server](1) ✓
[PM2] Process successfully started
┌────┬────────────────────┬──────────┬──────┬───────────┬──────────┬──────────┐
│ id │ name               │ mode     │ ↺    │ status    │ cpu      │ memory   │
├────┼────────────────────┼──────────┼──────┼───────────┼──────────┼──────────┤
│ 1  │ server             │ fork     │ 991  │ online    │ 0%       │ 13.8mb   │
└────┴────────────────────┴──────────┴──────┴───────────┴──────────┴──────────┘
Current process list running is not in sync with saved list. App app differs. Type 'pm2 save' to synchronize.

Everything works fine. But after few minutes pm2 has an error and restart in loop every 1 second :

2021-04-21T09:39:19: PM2 log: ===============================================================================
2021-04-21T09:39:19: PM2 log: --- New PM2 Daemon started ----------------------------------------------------
2021-04-21T09:39:19: PM2 log: Time                 : Wed Apr 21 2021 09:39:19 GMT+0000 (Coordinated Universal Time)
2021-04-21T09:39:19: PM2 log: PM2 version          : 4.5.5
2021-04-21T09:39:19: PM2 log: Node.js version      : 15.12.0
2021-04-21T09:39:19: PM2 log: Current arch         : x64
2021-04-21T09:39:19: PM2 log: PM2 home             : /home/debian/.pm2
2021-04-21T09:39:19: PM2 log: PM2 PID file         : /home/debian/.pm2/pm2.pid
2021-04-21T09:39:19: PM2 log: RPC socket file      : /home/debian/.pm2/rpc.sock
2021-04-21T09:39:19: PM2 log: BUS socket file      : /home/debian/.pm2/pub.sock
2021-04-21T09:39:19: PM2 log: Application log path : /home/debian/.pm2/logs
2021-04-21T09:39:19: PM2 log: Worker Interval      : 30000
2021-04-21T09:39:19: PM2 log: Process dump file    : /home/debian/.pm2/dump.pm2
2021-04-21T09:39:19: PM2 log: Concurrent actions   : 2
2021-04-21T09:39:19: PM2 log: SIGTERM timeout      : 1600
2021-04-21T09:39:19: PM2 log: ===============================================================================
2021-04-21T09:39:32: PM2 error: 2 : id unknown
2021-04-21T09:39:32: PM2 error: Trace: Error: 2 : id unknown
    at Object.God.logAndGenerateError (/home/debian/.nvm/versions/node/v15.12.0/lib/node_modules/pm2/lib/God/Methods.js:39:12)
    at Object.God.stopProcessId (/home/debian/.nvm/versions/node/v15.12.0/lib/node_modules/pm2/lib/God/ActionMethods.js:306:21)
    at God.deleteProcessId (/home/debian/.nvm/versions/node/v15.12.0/lib/node_modules/pm2/lib/God/ActionMethods.js:383:9)
    at Server.onmessage (/home/debian/.nvm/versions/node/v15.12.0/lib/node_modules/pm2/node_modules/pm2-axon-rpc/lib/server.js:104:6)
    at RepSocket.emit (node:events:369:20)
    at RepSocket.emit (node:domain:470:12)
    at Parser.<anonymous> (/home/debian/.nvm/versions/node/v15.12.0/lib/node_modules/pm2/node_modules/pm2-axon/lib/sockets/rep.js:51:15)
    at Parser.emit (node:events:369:20)
    at Parser.emit (node:domain:532:15)
    at Parser._write (/home/debian/.nvm/versions/node/v15.12.0/lib/node_modules/pm2/node_modules/amp/lib/stream.js:91:16)
    at Object.God.logAndGenerateError (/home/debian/.nvm/versions/node/v15.12.0/lib/node_modules/pm2/lib/God/Methods.js:34:15)
    at /home/debian/.nvm/versions/node/v15.12.0/lib/node_modules/pm2/lib/God/ActionMethods.js:384:30
    at Object.God.stopProcessId (/home/debian/.nvm/versions/node/v15.12.0/lib/node_modules/pm2/lib/God/ActionMethods.js:306:14)
    at God.deleteProcessId (/home/debian/.nvm/versions/node/v15.12.0/lib/node_modules/pm2/lib/God/ActionMethods.js:383:9)
    at Server.onmessage (/home/debian/.nvm/versions/node/v15.12.0/lib/node_modules/pm2/node_modules/pm2-axon-rpc/lib/server.js:104:6)
    at RepSocket.emit (node:events:369:20)
    at RepSocket.emit (node:domain:470:12)
    at Parser.<anonymous> (/home/debian/.nvm/versions/node/v15.12.0/lib/node_modules/pm2/node_modules/pm2-axon/lib/sockets/rep.js:51:15)
    at Parser.emit (node:events:369:20)
    at Parser.emit (node:domain:532:15)
2021-04-21T09:39:49: PM2 log: PM2 successfully stopped
2021-04-21T09:39:57: PM2 log: ===============================================================================
2021-04-21T09:39:57: PM2 log: --- New PM2 Daemon started ----------------------------------------------------
2021-04-21T09:39:57: PM2 log: Time                 : Wed Apr 21 2021 09:39:57 GMT+0000 (Coordinated Universal Time)
2021-04-21T09:39:57: PM2 log: PM2 version          : 4.5.5
2021-04-21T09:39:57: PM2 log: Node.js version      : 15.12.0
2021-04-21T09:39:57: PM2 log: Current arch         : x64
2021-04-21T09:39:57: PM2 log: PM2 home             : /home/debian/.pm2
2021-04-21T09:39:57: PM2 log: PM2 PID file         : /home/debian/.pm2/pm2.pid
2021-04-21T09:39:57: PM2 log: RPC socket file      : /home/debian/.pm2/rpc.sock
2021-04-21T09:39:57: PM2 log: BUS socket file      : /home/debian/.pm2/pub.sock
2021-04-21T09:39:57: PM2 log: Application log path : /home/debian/.pm2/logs
2021-04-21T09:39:57: PM2 log: Worker Interval      : 30000
2021-04-21T09:39:57: PM2 log: Process dump file    : /home/debian/.pm2/dump.pm2
2021-04-21T09:39:57: PM2 log: Concurrent actions   : 2
2021-04-21T09:39:57: PM2 log: SIGTERM timeout      : 1600
2021-04-21T09:39:57: PM2 log: ===============================================================================
2021-04-21T10:07:24: PM2 log: App [app:0] starting in -fork mode-
2021-04-21T10:07:24: PM2 log: App [app:0] online
2021-04-21T10:07:25: PM2 log: App [app:0] exited with code [1] via signal [SIGINT]
2021-04-21T10:07:25: PM2 log: App [app:0] starting in -fork mode-
2021-04-21T10:07:25: PM2 log: App [app:0] online
2021-04-21T10:07:26: PM2 log: App [app:0] exited with code [1] via signal [SIGINT]
2021-04-21T10:07:26: PM2 log: App [app:0] starting in -fork mode-
2021-04-21T10:07:26: PM2 log: App [app:0] online
2021-04-21T10:07:26: PM2 log: App [app:0] exited with code [1] via signal [SIGINT]
2021-04-21T10:07:26: PM2 log: App [app:0] starting in -fork mode-
2021-04-21T10:07:26: PM2 log: App [app:0] online

// infinite loop here

2021-04-21T10:07:27: PM2 log: App [app:0] exited with code [1] via signal [SIGINT]
2021-04-21T10:07:27: PM2 log: App [app:0] starting in -fork mode-
2021-04-21T10:07:27: PM2 log: App [app:0] online

Can someone help me to understand what’s wrong ? Everything works fine in localhost but make it works in production is very hard for me.

3

Answers


  1. Try and start your app without PM2, usually this indicates the node instance is failing so doing a regular node [appname] will generate where your node app is failing, probably a missing package.

    Login or Signup to reply.
  2. Read the message: the running process is not synchronized.

    You need to pm2 save.

    Follow the appropriate documentation.

    Login or Signup to reply.
  3. how about this?

    pm2 kill
    rm -rf ~/.pm2
    

    found pm2 github

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search