Forum

You are not logged in.

#1 02-10-2017 12:10:11

oncletom
Membre
From: London, United Kingdom
Registered: 15-04-2011
Posts: 9
Website

Bug or feature: evaluating Node.js environment variables in Command

Hi there,

I have been using the Node.js / User program feature with a great pleasure so far :-)
Although I have been surprised with the behaviour of the Command field.

This is an example command I typed:

npm start -- --port $ALWAYSDATA_HTTPD_PORT --hostname $ALWAYSDATA_HTTPD_IP --key $SECURE_KEY

`ALWAYSDATA_HTTPD_PORT` and `ALWAYSDATA_HTTPD_IP` are provided by Alwaysdata. `SECURE_KEY`is defined in the Environment field as `SECURE_KEY=something`.

So far so good.

Except my process failed to start… or I failed to connect to it because the environment variables where not populated at the command level. I could use them in my code but then it means having to change my code to handle the AD specific variables which I don't want to do.

I ended up hardcoding the port, hostname and secure key values in the Command field to make the app work properly.

Would not it be better to resolve the environment variables when evaluating the Command?
When porting applications from Heroku for example, then I have just to copy/paste the commands of the `Procfile` processes in the Command field, and dump the env variables in the Environment field.

Maybe it's a stupid idea or maybe I mistyped something :-)

Offline

#2 02-10-2017 12:13:41

@Cyril
Staff
From: Paris
Registered: 06-02-2007
Posts: 5,572
Website

Re: Bug or feature: evaluating Node.js environment variables in Command

Hi,

I'm pretty sure it should have worked: environment variables are supposed to be replaced. Can you open a support ticket by specifying the site ID? I'd like to have a look to find out what's wrong.

Offline

#3 02-10-2017 12:17:25

oncletom
Membre
From: London, United Kingdom
Registered: 15-04-2011
Posts: 9
Website

Re: Bug or feature: evaluating Node.js environment variables in Command

Cool, I will double check again before posting, just in case :nerdface:

Last edited by oncletom (02-10-2017 12:17:37)

Offline

Board footer

Powered by FluxBB