Ecosystem process file
Any time you change the ecosystem process file, the environment variables will be updated.
Set Environment
To set default environment variables via ecosystem file, you just need to declare them under the “env:” attribute:
module.exports = {
apps: [{
name: "app",
script: "./app.js",
env: {
NODE_ENV: "development"
},
env_test: {
NODE_ENV: "test",
},
env_staging: {
NODE_ENV: "staging",
},
env_production: {
NODE_ENV: "production",
}
}]
}
Then start it:
$ pm2 start ecosystem.config.js
As you might have noticed, there is also a part about the env_test, env_staging and env_production in the ecosystem file.
For example to use the env_production variables instead of the default ones you just need to pass the --env <env_name> option:
$ pm2 start ecosystem.config.js --env production
references:
https://pm2.io/docs/runtime/best-practices/environment-variables/
No comments:
Post a Comment