When deploying via pm2 ecosystem.js production setup, the environment variables defined in the ecosystem.js deployment configuration are not sent to the server like they are when running pm2 ecosystem.js production.
Is there a reason for this? Environment variables are just as important in the setup process as they are during redeployment. For example when initializing the app's database tables, you need the credentials to log into the DBMS.
Example ecosystem.js:
module.exports = {
...
deployment: {
production: {
...
"post-setup": "echo $TEST_VAR", // Prints empty line
"post-deploy": "echo $TEST_VAR", // Prints "abc"
env: {
TEST_VAR: "abc",
},
},
},
};
When deploying via
pm2 ecosystem.js production setup
, the environment variables defined in theecosystem.js
deployment configuration are not sent to the server like they are when runningpm2 ecosystem.js production
.Is there a reason for this? Environment variables are just as important in the setup process as they are during redeployment. For example when initializing the app's database tables, you need the credentials to log into the DBMS.
Example
ecosystem.js
: