reload icon indicating copy to clipboard operation
reload copied to clipboard

Fix PORT environment variable being ignored

Open porst17 opened this issue 5 years ago • 4 comments

I noticed that bin/reload does not respect the PORT environment variable contradicting

$ ./bin/reload --help | grep -A 2 -- --port
  -p, --port [port]              The port to bind to. Can be set with PORT env
                                 variable as well. Defaults to 8080. (default:
                                 "8080")

This provides a quick fix for this.

If provided, --port will take precedence.

porst17 avatar Dec 10 '20 09:12 porst17

Thanks for the PR and sorry for the long reply. Command line arguments are meant to task precedence over environment variables. With that being said I'm going to close this

(Light) Reference: https://stackoverflow.com/questions/11077223/what-order-of-reading-configuration-values

alallier avatar Jun 09 '21 18:06 alallier

My patch is respecting the order the StackOverflow post is proposing.

  • If --port [port] is present, port will be used (command line argument)
  • If --port [port] is not present, but the PORT environment variable is, then PORT is used (environment)
  • If PORT is not present, 8080 is used (global configuration)

My point was that the PORT environment variable is never used, even though the documentation says it does.

Your current implementation does the following:

  • If --port [port] is present, port will be used (command line argument)
  • If --port [port] is not present, 8080 is used (global configuration)

The doc says, PORT will be used, but it never is.

Example:

$ PORT=1234 npx reload .
npx: Installierte 52 in 2.739s

Reload web server:
listening on port 8080

The server should listen on port 1234, but instead it listens on 8080.

Please reconsider merging my PR.

porst17 avatar Jun 11 '21 06:06 porst17

Codecov Report

Merging #280 (8cda46a) into master (39f2dc8) will not change coverage. The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##            master      #280   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            2         2           
  Lines          131       131           
=========================================
  Hits           131       131           

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 39f2dc8...8cda46a. Read the comment docs.

codecov[bot] avatar Aug 24 '21 17:08 codecov[bot]

Thanks for reopening. Are there still any objections against merging this?

porst17 avatar Aug 30 '21 07:08 porst17