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
Set ENV["PORT"] to be used by default if defined. #377
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a comment
@@ -41,7 +41,7 @@ str = String.build do |s| | |||
#s.puts %(@log.level = #{settings["log_level"]? || "::Logger::INFO"}) | |||
s.puts %(@color = #{settings["color"]? == nil ? true : settings["color"]}) | |||
s.puts %(@redis_url = "#{settings["redis_url"]? || "redis://localhost:6379"}") | |||
s.puts %(@port = #{settings["port"]? || 3000}) | |||
s.puts %(@port = #{ENV["PORT"]? || settings["port"]? || 3000}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be (ENV["PORT"] ||= "3000").to_i
You can just do this on each of the environment YAMLs
secret_key_base: <%= SecureRandom.urlsafe_base64(32) %>
port: <%= (ENV["PORT"] ||= "3000").to_i %>
name: <%= @name %>
log: "::Logger.new(STDOUT)"
log_level: "::Logger::INFO"
color: true
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this file it shouldn't be (ENV["PORT"] ||= "3000").to_i
Just in the environment files. Do you prefer having it in each of the env yaml files? That was my original opinion but started second guessing that yesterday after reading your comments on it.
Would it maybe be better to let port be overridden by ENV["PORT"] regardless of what's in the env.yml?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@elorest I would expect the environment variable to override env.yml personally
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sam0x17 We'll it will be setup that way by default in the env.yml's but it gives you the option to change it to a different ENV VAR if you wanted. The default will still have PORT override though it will just be configured in development.yml, prod, test etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either way this will be fixed for you. 👍
This would have saved me some headaches with docker two weeks ago lol 👍 |
@elorest - Is this waiting on anything? |
* added envport by default * allowed ENV["PORT"] to be used by default if defined. * added env override to settings files.
* added envport by default * allowed ENV["PORT"] to be used by default if defined. * added env override to settings files. Former-commit-id: ea8021a
Description of the Change
Fixed small bug where
ENV["PORT"]
wasn't being used by default. I thought that it would be good to leave this more configurable, but agree that this might be confusing to users.