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

support PORT environment variable #120

Closed
wants to merge 1 commit into from
Closed

Conversation

cheslip
Copy link

@cheslip cheslip commented Jan 4, 2017

This enables the use of a PORT environment variable that is commonly used with PaaS services such as Heroku and Cloud Foundry. Still defaults to 3000 if the env var is not set.

@albinekb
Copy link
Contributor

albinekb commented Jan 4, 2017

Add it to the readme too? @cheslip 🎉

@timneutkens
Copy link
Member

@leo @rauchg This one can be merged after the proposed change. Will this have any negative effect? I can imagine people having PORT defined and using micro index.js. Though that might be an edge case 🤔

Copy link
Member

@timneutkens timneutkens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 👍

@@ -43,6 +43,12 @@ To run the microservice on port `3000` and localhost instead of listening on eve
$ micro -p 3000 -H localhost sleep.js
```

`micro` also supports using the PORT environment variable to set the port:
Copy link
Member

@timneutkens timneutkens Jan 4, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would turn PORT into PORT (wrap it in '`')

@rauchg
Copy link
Member

rauchg commented Jan 6, 2017

Why not micro -p $PORT? Not being explicit about it is somewhat strange

@cheslip
Copy link
Author

cheslip commented Jan 6, 2017

If done that way it won't default back to 3000 if $PORT isn't set which is useful for testing locally. On the other hand you could just do PORT=<port> micro -p $PORT so just a matter of preference.

@timneutkens
Copy link
Member

@rauchg @cheslip Ah, I thought it was related to Heroku and Cloud Foundry not being able to do -p 😅 micro -p $PORT avoids weird bugs 👍

@cheslip cheslip closed this Jan 6, 2017
@rauchg
Copy link
Member

rauchg commented Jan 6, 2017

@cheslip in that case we should make sure we default to 3000 if -p is supplied with no arguments or empty ones?

@timneutkens
Copy link
Member

@rauchg I'll have a look into that 👍

@cheslip
Copy link
Author

cheslip commented Jan 6, 2017

yes that should achieve similar behavior, thanks for looking into it

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

Successfully merging this pull request may close these issues.

4 participants