From 5f1ce1e0fc514d9195862c72cdfb9fc1e1cd0817 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20M=C3=BCller?= Date: Fri, 27 Oct 2017 18:15:29 +0200 Subject: [PATCH] Move signal trapping to Kemal::Application --- src/kemal/application.cr | 8 +++++++- src/kemal/base.cr | 7 ------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/kemal/application.cr b/src/kemal/application.cr index 5aca0037..0222d5b5 100644 --- a/src/kemal/application.cr +++ b/src/kemal/application.cr @@ -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"] diff --git a/src/kemal/base.cr b/src/kemal/base.cr index 1b9872b1..e1451012 100644 --- a/src/kemal/base.cr +++ b/src/kemal/base.cr @@ -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)