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

Set ENV["PORT"] to be used by default if defined. #377

Merged
merged 7 commits into from Nov 12, 2017

Conversation

elorest
Copy link
Member

@elorest elorest commented Nov 10, 2017

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.

Copy link
Contributor

@eliasjpr eliasjpr left a 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})
Copy link
Contributor

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
...

Copy link
Member Author

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?

Copy link
Contributor

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

Copy link
Member Author

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.

Copy link
Member Author

@elorest elorest Nov 10, 2017

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. 👍

@sam0x17
Copy link
Contributor

sam0x17 commented Nov 10, 2017

This would have saved me some headaches with docker two weeks ago lol 👍

@marksiemers marksiemers added this to the 0.4.0 - Features & Bugfixes milestone Nov 11, 2017
@marksiemers
Copy link
Contributor

@elorest - Is this waiting on anything?

@elorest elorest merged commit 754fd22 into master Nov 12, 2017
@eliasjpr eliasjpr deleted the is/default_to_ENVport branch November 12, 2017 23:41
elorest added a commit that referenced this pull request Nov 17, 2017
* added envport by default

* allowed ENV["PORT"] to be used by default if defined.

* added env override to settings files.
elorest added a commit that referenced this pull request Nov 17, 2017
* added envport by default

* allowed ENV["PORT"] to be used by default if defined.

* added env override to settings files.


Former-commit-id: ea8021a
@faustinoaq faustinoaq added this to Done in Framework 2018 May 5, 2018
@faustinoaq faustinoaq removed this from Done in Framework 2018 Jun 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

5 participants