diff options
Diffstat (limited to 'railties/lib/rails/commands/server/server_command.rb')
-rw-r--r-- | railties/lib/rails/commands/server/server_command.rb | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/railties/lib/rails/commands/server/server_command.rb b/railties/lib/rails/commands/server/server_command.rb index 64fb912b51..77b6c1f65d 100644 --- a/railties/lib/rails/commands/server/server_command.rb +++ b/railties/lib/rails/commands/server/server_command.rb @@ -43,15 +43,15 @@ module Rails ENV["RAILS_ENV"] ||= options[:environment] end - def start + def start(after_stop_callback = nil) trap(:INT) { exit } create_tmp_directories setup_dev_caching log_to_stdout if options[:log_stdout] - super + super() ensure - yield + after_stop_callback.call if after_stop_callback end def serveable? # :nodoc: @@ -157,9 +157,8 @@ module Rails if server.serveable? print_boot_information(server.server, server.served_url) - server.start do - say "Exiting" unless options[:daemon] - end + after_stop_callback = -> { say "Exiting" unless options[:daemon] } + server.start(after_stop_callback) else say rack_server_suggestion(using) end @@ -220,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 @@ -235,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 @@ -284,10 +293,10 @@ module Rails Run `rails server --help` for more options. MSG else - suggestions = Rails::Command::Spellchecker.suggest(server, from: RACK_SERVERS).map(&:inspect) + suggestions = Rails::Command::Spellchecker.suggest(server, from: RACK_SERVERS) <<~MSG - Could not find server "#{server}". Maybe you meant #{suggestions.first} or #{suggestions.second}? + Could not find server "#{server}". Maybe you meant #{suggestions.inspect}? Run `rails server --help` for more options. MSG end |