achingbrain / pm2-web

A web based monitor for PM2
539 stars 90 forks source link

No cpu usage in fork mode #36

Closed xShirase closed 9 years ago

xShirase commented 10 years ago

I don't see any CPU usage if I start my script in fork mode (with or without -x, no difference).However, the load average is computed properly. My machine has 4 CPUs and my script uses node-cluster, which may be relevant to the issue, as it uses all 4CPUs. However, I'm surprised to see it stuck at 0.00%. If I launch the script in cluster mode, it shows the right values (but as I already use node cluster... kinda useless, no?)

I attached a minimal version of the script if you want to test, I'll probably remove the cluster stuff anyway, I had totally forgotten that pm2 had it integrated...

var cluster = require('cluster'); var clusterWorkerSize = require('os').cpus().length; if (cluster.isMaster) { for (var i = 0; i < clusterWorkerSize; i++) { cluster.fork(); } } else { //do long worker stuff here }