Unitech / pm2-deploy

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

feat: pass env to post-deploy #152

Closed phra closed 6 years ago

phra commented 6 years ago

fixes #102

lardissone commented 6 years ago

@vmarchaud it's already merged to pm2? I still can't see the env vars from deploy within my app.

phra commented 6 years ago

@lardissone can you clone this repository and npm link this package in your project to see if it fixes the problem? thanks.

lardissone commented 6 years ago

@phra I've linked the repo and seems to work from client side. At least it executes the post-deploy with the ENV vars correctly.

Previously:

  ○ executing post-deploy `npm install && pm2 startOrRestart pm2.config.js --env production`

After fix:

  ○ executing post-deploy `export NODE_ENV=production PORT=8400 JWT_SECRET=[redacted] JWT_EXPIRATION_MINUTES=60 MONGO_URI=[redacted] MONGO_URI_TESTS=[redacted] && npm install && pm2 startOrRestart pm2.config.js --env production`

But env vars are still not available within the app on the server.

vmarchaud commented 6 years ago

you should use pm2 startOrReload pm2.config.js --env production --update-env to tell PM2 to actually pickup the new environment and inject it inside the new processes

lardissone commented 6 years ago

@vmarchaud I've added --update-env and still no luck trying to access process.env.JWT_SECRET for example.

phra commented 6 years ago

i will try to debug it..

phra commented 6 years ago

@lardissone pls create a new ticket regarding the --update-env bug. thanks.