Search code examples
node.jspm2forever

nodejs Running something on only a single process pm2


I'm using pm2 to start multiple processes of my server pm2 start server.js -i max. There's something I want to run only on a single process though and not all of them. AFAIK pm2 does not have a concept of a master process. I don't see any markers under process. I also would prefer not to have a config that fixes the number of processes I have instead of letting it be based on CPU cores.


Solution

  • Someone let me know if this is correct: I can check if process.ppid === process.pid. The other processes are started from one process and we can let that process act as the master.