简体   繁体   中英

How run pm2 with special script for prod env?

I already have the dev app run on pm2. I wanna add the app for production.

I have a script in the package:

"scripts": {
    "pm2-start-prod": "set NODE_ENV=production&& pm2 start app.js",
...
}

I tried to run pm2 start "npm run pm2-start-prod" --name backend-prod

But in pm2 appear 2 new instance app and backend-prod.

Both don't work the app logs shows 8082 port already used

backend-prod can't run script pm2-start-prod

I know I should use ecosystem, but I don't understand how.

What I did do wrong?

I think this should be working

pm2 start "whatEverScript" --name whateverName

in your case this correct

pm2 start "npm run pm2-start-prod" --name backend-prod

I think the problem in your script it should be something like this

"scripts": {
    "pm2-start-prod": "set NODE_ENV=production&& node app.js",
...
}

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