Pm2: Allow to change name when starting from ecosystem.json

Created on 2 Feb 2016  路  4Comments  路  Source: Unitech/pm2

For pm2 testing purposes I am currently running both staging and production environment on the same machine. However, since both script are named the same - I will only get one instance running.

My initial thoughts was "let's add NODE_ENV to the name!", no luck, process.env.NODE_ENV is not available at this point.

Second try, let's pass --name to post-deploy script starting up, no luck, --name is ignored when starting from ecosystem.json

Most helpful comment

Not sure what I did before, this does work however;

"name": "awesome-app-" + (process.env.NODE_ENV || "local"),
...
"post-deploy": "npm install; export NODE_ENV=development; pm2 startOrRestart ecosystem.json --env development"

All 4 comments

Not sure what I did before, this does work however;

"name": "awesome-app-" + (process.env.NODE_ENV || "local"),
...
"post-deploy": "npm install; export NODE_ENV=development; pm2 startOrRestart ecosystem.json --env development"

I think what you were missing was --force, which tells PM2 that it is okay to start the same script more than once and treat them separately.

For anyone else that runs into this, you can create 2 different apps in the apps array, but put 1 env for each app. This way you can stick with 1 file.

I worked it out using append_env_to_name: true that appends environment name to app name.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mario-mui picture mario-mui  路  3Comments

rangercyh picture rangercyh  路  4Comments

getvega picture getvega  路  3Comments

ghost picture ghost  路  3Comments

alexpts picture alexpts  路  3Comments