diff --git a/spec/config_spec.cr b/spec/config_spec.cr index 31a8438..daa6849 100644 --- a/spec/config_spec.cr +++ b/spec/config_spec.cr @@ -58,4 +58,11 @@ describe "Config" do it "gets the version from shards.yml" do Kemal::VERSION.should_not be("") end + + it "sets application name" do + config = Kemal.config + config.app_name.should eq "Kemal" + config.app_name = "testapp" + config.app_name.should eq "testapp" + end end diff --git a/src/kemal.cr b/src/kemal.cr index 5504b5c..6f1a564 100644 --- a/src/kemal.cr +++ b/src/kemal.cr @@ -67,11 +67,11 @@ module Kemal def self.display_startup_message(config, server) addresses = server.addresses.join ", " { |address| "#{config.scheme}://#{address}" } - log "[#{config.env}] Kemal is ready to lead at #{addresses}" + log "[#{config.env}] #{config.app_name} is ready to lead at #{addresses}" end def self.stop - raise "Kemal is already stopped." if !config.running + raise "#{Kemal.config.app_name} is already stopped." if !config.running if server = config.server server.close unless server.closed? config.running = false @@ -90,7 +90,7 @@ module Kemal private def self.setup_trap_signal Signal::INT.trap do - log "Kemal is going to take a rest!" if Kemal.config.shutdown_message + log "#{Kemal.config.app_name} is going to take a rest!" if Kemal.config.shutdown_message Kemal.stop exit end diff --git a/src/kemal/config.cr b/src/kemal/config.cr index 2efcd66..4e62d8d 100644 --- a/src/kemal/config.cr +++ b/src/kemal/config.cr @@ -24,9 +24,10 @@ module Kemal property always_rescue, server : HTTP::Server?, extra_options, shutdown_message property serve_static : (Bool | Hash(String, Bool)) property static_headers : (HTTP::Server::Response, String, File::Info -> Void)? - property powered_by_header : Bool = true + property powered_by_header : Bool = true, app_name def initialize + @app_name = "Kemal" @host_binding = "0.0.0.0" @port = 3000 @env = ENV["KEMAL_ENV"]? || "development"