From c08bf71d880e3590af3fe975a5ead8c926ca31be Mon Sep 17 00:00:00 2001 From: Michael Barrett Date: Wed, 18 Jan 2017 07:55:33 -0500 Subject: [PATCH] Allow for disabling the shutdown message (#292) Allow for disabling the shutdown message --- spec/config_spec.cr | 8 ++++++++ src/kemal.cr | 2 +- src/kemal/config.cr | 4 +++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/spec/config_spec.cr b/spec/config_spec.cr index 9ed90ee..e5460a1 100644 --- a/spec/config_spec.cr +++ b/spec/config_spec.cr @@ -29,6 +29,14 @@ describe "Config" do config.handlers.size.should eq(6) end + it "toggles the shutdown message" do + config = Kemal.config + config.shutdown_message = false + config.shutdown_message.should eq false + config.shutdown_message = true + config.shutdown_message.should eq true + end + it "adds custom options" do config = Kemal.config ARGV.push("--test") diff --git a/src/kemal.cr b/src/kemal.cr index 05b638d..a4981cd 100644 --- a/src/kemal.cr +++ b/src/kemal.cr @@ -41,7 +41,7 @@ module Kemal # Test environment doesn't need to have signal trap, built-in images, and logging. unless config.env == "test" Signal::INT.trap { - log "Kemal is going to take a rest!\n" + log "Kemal is going to take a rest!\n" if config.shutdown_message Kemal.stop exit } diff --git a/src/kemal/config.cr b/src/kemal/config.cr index 4d05471..3454154 100644 --- a/src/kemal/config.cr +++ b/src/kemal/config.cr @@ -15,7 +15,8 @@ module Kemal {% end %} property host_binding, ssl, port, env, public_folder, logging, running, - always_rescue, serve_static : (Bool | Hash(String, Bool)), server, extra_options + always_rescue, serve_static : (Bool | Hash(String, Bool)), server, extra_options, + shutdown_message def initialize @host_binding = "0.0.0.0" @@ -32,6 +33,7 @@ module Kemal @custom_handler_position = 4 @default_handlers_setup = false @running = false + @shutdown_message = true end def logger