Recently, I took over a company's predecessor project to use pm2 for process management, but I found that every time I run it, 4 processes are created, but the project tester kernel does not allow the creation of four processes at one time, so I plan to change the project configuration and change ecosystem.config. The configuration of instances in the js file was changed from 4 to 1. I thought it would be all right now, but I didn't expect to create four processes after running again. The solution I found later: delete all the processes first, then restart and OK!
The specific running command depends on how you configure it in your package.json. The configuration of my package.json is as follows:
"scripts": {
"dev": "node ./bin/server.js",
"build": "rm -rf ./.next/static && next build",
"start": "next start",
"export": "rm -rf ./dist && next export -o ./dist",
"pm2:start": "npm run build && pm2 startOrRestart ecosystem.config.js --env production",
"pm2:stop": "pm2 stop www.qqhs.org",
"pm2:delete": "pm2 delete www.qqhs.org"
}
So I need to:
npm run pm2:delete
after that
npm run pm2:start
Or if it is not too troublesome, you can use pm2 delete id | all to delete all processes ~