NodeJS and PM2, do not arrow environment variables

0

Hello, Good evening, everyone, I have a problem with setting my environment variables. I have the following json running on PM2:

module.exports = {
  "apps" : [{
    "name"       : "frontend-homologacao",
    "script"     : "/var/www/html/site_homologacao/frontend.sh",
    "exec_interpreter": "bash",
    "exec_mode"  : "fork_mode"
  }, {
    "name"       : "backend-homologacao",
    "script"     : "/var/www/html/site_homologacao/backend.sh",
    "exec_interpreter": "bash",
    "exec_mode"  : "fork_mode"
  }]

};

And no bash backend.sh:

PORT=4001 HOSTNAME=homologacao.meudominio.com APP=homolog ENV_TEST=tests node /var/www/html/site_homologacao/server/restapi.js
But when I run pm2 start ecosystem.config.js it runs and starts normally the NodeJs server but I can not capture the values of the variables using process.env.HOSTNAME or else it comes with a default value that does not make sense with what was set in BASH.

Thanks in advance for your attention.

    
asked by anonymous 16.08.2018 / 01:56

0 answers