简体   繁体   中英

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.

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.

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