aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
authoryuuji.yaginuma <yuuji.yaginuma@gmail.com>2018-03-10 19:43:31 +0900
committeryuuji.yaginuma <yuuji.yaginuma@gmail.com>2018-03-10 19:43:31 +0900
commit9af6601a46ec6afeafc61597eb10bdc7f175370d (patch)
tree3df33e809f48cbc9e0f0bb7678d0c67a8879bb81 /railties
parent38c7ddd4e9f3f22f67d9615dd04a2ae9525824fb (diff)
downloadrails-9af6601a46ec6afeafc61597eb10bdc7f175370d.tar.gz
rails-9af6601a46ec6afeafc61597eb10bdc7f175370d.tar.bz2
rails-9af6601a46ec6afeafc61597eb10bdc7f175370d.zip
Do not show unnecessary message during server startup
Currently, `Exiting` is showed during server startup. ``` ./bin/rails s => Booting Puma => Rails 6.0.0.alpha application starting in development => Run `rails server --help` for more startup options Exiting Puma starting in single mode... * Version 3.11.2 (ruby 2.5.0-p0), codename: Love Song ``` This is because processing at server stop is passed as a block, and `Rack::Serve#start` receives a block and executes it during startup processing. https://github.com/rack/rack/blob/50db1ffdf8b98503fb7c6e6648622b5d7d78d58e/lib/rack/server.rb#L258 In order to avoid this, stop processing is passed as argument.
Diffstat (limited to 'railties')
-rw-r--r--railties/lib/rails/commands/server/server_command.rb11
1 files changed, 5 insertions, 6 deletions
diff --git a/railties/lib/rails/commands/server/server_command.rb b/railties/lib/rails/commands/server/server_command.rb
index 64fb912b51..8588e2fd64 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