diff options
author | Kasper Timm Hansen <kaspth@gmail.com> | 2018-07-07 10:09:45 +0200 |
---|---|---|
committer | Kasper Timm Hansen <kaspth@gmail.com> | 2018-07-07 10:21:29 +0200 |
commit | 161ed37d7120e1f391eed19e49a3390e53e4fe91 (patch) | |
tree | 6466c02cb6afbcc36ee2f3c203cc6ad2834781a5 /railties/lib/rails/commands/server | |
parent | 688e48d93d7e4d7d66a726e024e1a262bbf31b17 (diff) | |
download | rails-161ed37d7120e1f391eed19e49a3390e53e4fe91.tar.gz rails-161ed37d7120e1f391eed19e49a3390e53e4fe91.tar.bz2 rails-161ed37d7120e1f391eed19e49a3390e53e4fe91.zip |
Don't show unneeded deprecation warning on server restart.
If booting a server via `rails s -u puma`, we'd convert the
option to a `using` positional.
When using `rails restart` our `restart_command` would the
option converted to the using positional and put that in
the restart command.
Thus we'd show users deprecation warnings for our own code.
Fix that by converting a passed positional to an option instead.
Also: fix initialize method signature. The local_options are an
array, not a hash. But don't even bother assigning defaults as
Thor passes them in.
Diffstat (limited to 'railties/lib/rails/commands/server')
-rw-r--r-- | railties/lib/rails/commands/server/server_command.rb | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/railties/lib/rails/commands/server/server_command.rb b/railties/lib/rails/commands/server/server_command.rb index 2aa663cc0d..95ac497b2e 100644 --- a/railties/lib/rails/commands/server/server_command.rb +++ b/railties/lib/rails/commands/server/server_command.rb @@ -133,10 +133,11 @@ module Rails class_option :restart, type: :boolean, default: nil, hide: true class_option :early_hints, type: :boolean, default: nil, desc: "Enables HTTP/2 early hints." - def initialize(args = [], local_options = {}, config = {}) - @original_options = local_options + def initialize(args, local_options, *) super - @using = deprecated_positional_rack_server(using) || options[:using] + + @original_options = local_options + deprecate_positional_rack_server_and_rewrite_to_option(@original_options) @log_stdout = options[:daemon].blank? && (options[:environment] || Rails.env) == "development" end @@ -248,7 +249,7 @@ module Rails end def restart_command - "bin/rails server #{using} #{@original_options.join(" ")} --restart" + "bin/rails server #{@original_options.join(" ")} --restart" end def early_hints @@ -267,14 +268,19 @@ module Rails FileUtils.rm_f(options[:pid]) if options[:restart] end - def deprecated_positional_rack_server(value) - if value - ActiveSupport::Deprecation.warn(<<-MSG.squish) + def deprecate_positional_rack_server_and_rewrite_to_option(original_options) + if using + ActiveSupport::Deprecation.warn(<<~MSG) Passing the Rack server name as a regular argument is deprecated and will be removed in the next Rails version. Please, use the -u option instead. MSG - value + + original_options.concat [ '-u', using ] + else + # Use positional internally to get around Thor's immutable options. + # TODO: Replace `using` occurences with `options[:using]` after deprecation removal. + @using = options[:using] end end |