Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passing environmental variables to the script ... #33

Closed
codevin opened this issue Jun 27, 2013 · 4 comments
Closed

Passing environmental variables to the script ... #33

codevin opened this issue Jun 27, 2013 · 4 comments

Comments

@codevin
Copy link

codevin commented Jun 27, 2013

Let us say I want to do:

PORT=8080 pm2 start -i 4 app.js

I expect that the environment variable will be available to the script. (And I am not able to receive it.) I am trying to find why I am not able to see that variable.

Before I dig deeper, could you confirm (by updating the documentation) that environmental variables are indeed available?

@Unitech
Copy link
Owner

Unitech commented Jul 1, 2013

The entire environment is passed to child scripts. I just tested now and it works

@Unitech Unitech closed this as completed Jul 1, 2013
@manast
Copy link

manast commented Jan 9, 2014

It works when using start, but at least for restart command it does not work, it keeps using the same environment as the one available when the app was initially started.
So if I have a script: app.js:

console.log(process.env[NODE_ENV]);

If I do:

NODE_ENV=test pm2 start app.js

It will output test, but if I then do:

NODE_ENV=development pm2 restart app.js

It will still output test.
Intended or not, seems a bit counter intuitive to me :).

@manast
Copy link

manast commented Jan 9, 2014

actually it gets worse. The same effect as above is achieved if instead of restart you use start on a stopped process...

@matejkramny
Copy link

Can it be modified when the process is running? (assuming you change the ENV variables, then restart)

Matej Kramny

On Thursday, 9 January 2014 at 11:59, Manuel Astudillo wrote:

actually it gets worse. The same effect as above is achieved if instead of restart you use start on a stopped process...


Reply to this email directly or view it on GitHub (#33 (comment)).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants