简体   繁体   中英

Pm2 running multiple instances by default in fork mode

I have a very simple app.js file

 console.log("testing"); 

Running this with pm2 with the following command :

pm2 start app.js

This prints the lines below when doing pm2 logs 0;

0|app      | testing
0|app      | testing
0|app      | testing
0|app      | testing
0|app      | testing .. some more times as well.

I dont understand this behavior. Why is pm2 running this file multiple times. I have not specified any number of instances. Is default behavior is to spawn multiple instances by default in fork mode.

It does work fine when I specify instances to 1 and starts using the cluster mode. Official documentation doesn't help much.

try this : pm2 list then show what is ur process running after that u can use this : pm2 reload [AppName]
if this not working check ur code u may have any error

These logs might be due to multiple time execution of your application. Might be your application is getting restart multiple times hence multiple logging of the same console log. Check the number of restarts in pm2 list output.

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