Fix server options to respect port specficied in arch-cli's serve - #84
Fix server options to respect port specficied in arch-cli's serve#84chrisvfritz wants to merge 0 commit into
Conversation
|
Once this is in btw, I'm happy to write a quick doc on deploying to Heroku. Everything seems to be working after only minimal configuration. 😃 |
There was a problem hiding this comment.
can we make it process.env.ARCH_PORT || 3000? In case you run the server without the CLI and don't set anything in your environment
|
Thinking about it a bit more, I'm not sure whether the defaults are the right place to do this (it seems odd that you can affect the defaults by changing https://github.com/arch-js/arch/blob/master/bin/server.js#L3 @tabazevedo How was this supposed to work? :) |
|
@charypar @chrisvfritz yep, it should be I have some stuff mostly working with loading config file using https://github.com/dominictarr/rc which also reads env. Am happy to merge this though (once the default port 3000 is added). You will be able to pass arguments in as well (you can already, its just a bit clunky and undocumented), so the config priority is server(options) > env > defaults. |
|
Done! |
|
@tabazevedo are you not bothered by affecting defaults by environment? I admit it's a completely academic debate, but still :) Imagine you use the server module from a different binary, want to keep the port on default but have |
|
I personally don't have a problem with the environment overriding defaults, but I think it would be good to be a little more explicit in the override priority, a la: default-options = ...
env-options = ...
cli-options = ...
options = ^^default-options import ^^env-options import cli-optionsAs it is right now, there really is no |
|
Hmm.. it made sense in my head. Hardcoded stuff takes priority over dynamic env stuff which takes priority over defaults. |
|
@chrisvfritz yeah, that's because the sever binary just doesn't take any and pass them in to the server module. That's kind of what I meant... we should pass options in in all cases, even when they come from environment and otherwise use defaults. There shouldn't be a middle ground, i.e. using an environment variable is a caller's choice, not a server implementation behaviour. Hope that makes sense, it's a really tiny nuance :) |
|
I agree with @charypar. And I actually like the override priority you're using @tabazevedo, it's just a question of Where Should Stuff Go. 😃 |
This fixes this issue on arch-cli, which really turned out to be an issue here. However, I also discovered that the options passed to the arch server binary are always
undefined. I'm not sure if that's expected or not, but thought I'd mention it.