Closed BrandonCopley closed 6 years ago
Here is a script, and the NODE_ENV variable in Node will NEVER be set to anything but "undefined"
{
"apps": [{
"name": "name",
"script": "web.js",
"instances": 2,
"env": {
"PORT": <port>
},
"env_production": {
"NODE_ENV": "production"
},
"env_development": {
"NODE_ENV": "development"
}
}],
"deploy": {
"production": {
"user": "admin",
"host": ["x.x.x.x"],
"ref": "origin/master",
"repo": "<url>",
"path": "pm2",
"instances": "max",
"exec_mode": "cluster",
"post-deploy": "npm run deploy",
"env": {
"NODE_ENV": "production"
}
},
"development": {
"user": "admin",
"host": ["x.x.x.x"],
"ref": "origin/master",
"repo": "<url>",
"path": "pm2",
"instances": "max",
"exec_mode": "cluster",
"post-deploy": "npm run deploy",
"env": {
"NODE_ENV": "development"
}
}
}
}
The challenge here is that pm2-deploy won't ever generate your environment variables that are deployment specific.
Evidently this no longer happens automatically, and command line commands have to be given to change environment variables. not a bad call. http://pm2.keymetrics.io/docs/usage/application-declaration/#switching-to-different-environments
@BrandonCopley if what are you stating it's true, reopen the issue. in that case i will try to reproduce the bug.
It is not a "bug" but unfortunately a feature that I just missed that came in with v2.x.x it appears. - http://pm2.keymetrics.io/docs/usage/deployment/#use-different-set-of-env-variables
-- [image: Giftnix]
Brandon Copley
Founder & CEO
t: 512.784.6060 <(512)%20784-6060>
e: copley.brandon@gmail.com
On Tue, Oct 10, 2017 at 3:25 PM, Francesco Soncina <notifications@github.com
wrote:
@BrandonCopley https://github.com/brandoncopley if what are you stating it's true, reopen the issue. in that case i will try to reproduce the bug.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Unitech/pm2-deploy/issues/148#issuecomment-335596928, or mute the thread https://github.com/notifications/unsubscribe-auth/ABJShuanDgE84V3VBMZQYvPt5ybv6Tkdks5sq9LGgaJpZM4P0cDc .
I see.
Fixed by @phra on https://github.com/Unitech/pm2-deploy/commit/0225b00b7ec9b1b9da7a47de4ee7c96034bf017c.
Kickin the dead dog because I were tricked by 2.10.1 and needed to update. Maybe this is the case of anyone else.
We are seeing that blocks such as "env_production" and "env_development" and under
are being ignored. only the master block in
will set the environment variables correctly.