aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib
diff options
context:
space:
mode:
authorYuji Yaginuma <yuuji.yaginuma@gmail.com>2018-04-16 14:35:13 +0900
committerGitHub <noreply@github.com>2018-04-16 14:35:13 +0900
commit37b373a8d2a1cd132bbde51cd5a3abd4ecee433b (patch)
tree251b0e592cb53b15b835aea95d88466d04cc65a0 /railties/lib
parentd472229f1fb76f73b6bc678191057a554ce52f51 (diff)
downloadrails-37b373a8d2a1cd132bbde51cd5a3abd4ecee433b.tar.gz
rails-37b373a8d2a1cd132bbde51cd5a3abd4ecee433b.tar.bz2
rails-37b373a8d2a1cd132bbde51cd5a3abd4ecee433b.zip
Deprecate support for using `HOST` environment to specify server IP (#32540)
At SuSE, `$HOST` is set by default and is equal to `$HOSTNAME`. https://www.suse.com/documentation/sled11/book_sle_admin/data/sec_adm_variables.html Therefore, by default, it binds to hostname instead of `localhost`. This seems not to be appropriate as default behavior. In order to avoid the name of the environment variable being used, I changed the environment variable from `HOST` to `BINDING`. Fixes #29516.
Diffstat (limited to 'railties/lib')
-rw-r--r--railties/lib/rails/commands/server/server_command.rb14
1 files changed, 12 insertions, 2 deletions
diff --git a/railties/lib/rails/commands/server/server_command.rb b/railties/lib/rails/commands/server/server_command.rb
index 6da300e356..77b6c1f65d 100644
--- a/railties/lib/rails/commands/server/server_command.rb
+++ b/railties/lib/rails/commands/server/server_command.rb
@@ -219,7 +219,7 @@ module Rails
user_supplied_options << name
end
end
- user_supplied_options << :Host if ENV["HOST"]
+ user_supplied_options << :Host if ENV["HOST"] || ENV["BINDING"]
user_supplied_options << :Port if ENV["PORT"]
user_supplied_options.uniq
end
@@ -234,7 +234,17 @@ module Rails
options[:binding]
else
default_host = environment == "development" ? "localhost" : "0.0.0.0"
- ENV.fetch("HOST", default_host)
+
+ if ENV["HOST"] && !ENV["BINDING"]
+ ActiveSupport::Deprecation.warn(<<-MSG.squish)
+ Using the `HOST` environment to specify the IP is deprecated and will be removed in Rails 6.1.
+ Please use `BINDING` environment instead.
+ MSG
+
+ return ENV["HOST"]
+ end
+
+ ENV.fetch("BINDING", default_host)
end
end