18

I have an express server running with pm2(v2.4.2) and node(v7.7.4). Here is the pm2 list screenshot:

enter image description here

Here is htop screenshot:

enter image description here

As you can see, the CPU usage is 100%. And the running PIDs are not match with pm2 list. My server would get no response after a few hours or days. I can't find any log from pm2.log file. Sometimes pm2 restart fix this. But sometimes I can't execute any pm2 commands. I need to kill pm2 process by ps -Af | grep pm2 | awk '{print $2}' | xargs kill -9 and then restart.
So where are these two high cpu usage processes come from? That's why my server no response?

Hom
  • 421
  • 1
  • 4
  • 7
  • Your server not responding is because the CPU is at 100%. 1. When you run PM2 run pm2 list all .. see if that is what is eating up the cpu. However, from the log *it seems* that these are 2 other unrelated processes (not from PM2). See what else is running on your server, besides node. – twg Mar 31 '17 at 13:57
  • @twg The first screenshot is the result for `pm2 list all`. There is no other thing running on this server. I didn't see 2 other unrelated processes you said. `node /root/git/feserver/bin/www` is my project entrance. The most confused thing is the running PIDs not match `pm2 list` result. – Hom Apr 01 '17 at 05:42
  • Based on your OS you should be able to get the name of the process running on those mysterious PID numbers. take a look here [StackOverflow](https://superuser.com/questions/632979/if-i-know-the-pid-number-of-a-process-how-can-i-get-its-name) – twg Apr 01 '17 at 06:14
  • @Hom have you fixed the problem or is it still happening?. Are you using `chokidar` or watching file system changes? I had a similar problem a month ago. – Marcos Casagrande Apr 15 '17 at 04:58
  • 1
    @MarcosCasagrande still happening. I don't use `chokidar` nor watching file changes. I wrote a cpu usage guard process to fix this. Here is the [gist](https://gist.github.com/yanzhihong23/c9618d672eee0f467af872ea23a9f39c) – Hom Apr 28 '17 at 10:31
  • Did anybody try the solution on https://github.com/Unitech/pm2/issues/141#issuecomment-49285837 ?? – Gokul N K Oct 31 '20 at 07:05

1 Answers1

7

If it can help someone, I had the same problem and I have fixed this by fallowing this update procedure PM2 - Update and updated the startup setup script (copy/paste command). This problem seam to appear after upgrading Node, it may also help to npm update your servers running under PM2 after a Node version upgrade.

WebSam101
  • 101
  • 2
  • 5