Move signal trapping to Kemal::Application

This commit is contained in:
Johannes Müller 2017-10-27 18:15:29 +02:00 committed by sdogruyol
parent e6dc494f7e
commit 5f1ce1e0fc
2 changed files with 7 additions and 8 deletions

View file

@ -19,8 +19,14 @@ class Kemal::Application < Kemal::Base
end
end
# Test environment doesn't need to have signal trap, built-in images, and logging.
# Test environment doesn't need to have signal trap and built-in images.
unless @config.env == "test"
Signal::INT.trap do
log "Kemal is going to take a rest!" if @config.shutdown_message?
stop if running?
exit
end
# This route serves the built-in images for not_found and exceptions.
self.get "/__kemal__/:image" do |env|
image = env.params.url["image"]

View file

@ -77,13 +77,6 @@ class Kemal::Base
end
private def prepare_for_server_start
unless @config.env == "test"
Signal::INT.trap do
log "Kemal is going to take a rest!" if @config.shutdown_message?
stop if running?
exit
end
end
end
private def start_server(port)