Unitech / pm2-deploy

Deploy part of PM2
http://pm2.keymetrics.io/docs/usage/deployment/
MIT License
178 stars 72 forks source link

Environment variables not present during setup process #195

Open paulkre opened 3 years ago

paulkre commented 3 years ago

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",
      },
    },
  },
};