New option to set application name (#606)
This commit is contained in:
parent
3fee068636
commit
de5e022222
3 changed files with 12 additions and 4 deletions
|
@ -58,4 +58,11 @@ describe "Config" do
|
||||||
it "gets the version from shards.yml" do
|
it "gets the version from shards.yml" do
|
||||||
Kemal::VERSION.should_not be("")
|
Kemal::VERSION.should_not be("")
|
||||||
end
|
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
|
end
|
||||||
|
|
|
@ -67,11 +67,11 @@ module Kemal
|
||||||
|
|
||||||
def self.display_startup_message(config, server)
|
def self.display_startup_message(config, server)
|
||||||
addresses = server.addresses.join ", " { |address| "#{config.scheme}://#{address}" }
|
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
|
end
|
||||||
|
|
||||||
def self.stop
|
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
|
if server = config.server
|
||||||
server.close unless server.closed?
|
server.close unless server.closed?
|
||||||
config.running = false
|
config.running = false
|
||||||
|
@ -90,7 +90,7 @@ module Kemal
|
||||||
|
|
||||||
private def self.setup_trap_signal
|
private def self.setup_trap_signal
|
||||||
Signal::INT.trap do
|
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
|
Kemal.stop
|
||||||
exit
|
exit
|
||||||
end
|
end
|
||||||
|
|
|
@ -24,9 +24,10 @@ module Kemal
|
||||||
property always_rescue, server : HTTP::Server?, extra_options, shutdown_message
|
property always_rescue, server : HTTP::Server?, extra_options, shutdown_message
|
||||||
property serve_static : (Bool | Hash(String, Bool))
|
property serve_static : (Bool | Hash(String, Bool))
|
||||||
property static_headers : (HTTP::Server::Response, String, File::Info -> Void)?
|
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
|
def initialize
|
||||||
|
@app_name = "Kemal"
|
||||||
@host_binding = "0.0.0.0"
|
@host_binding = "0.0.0.0"
|
||||||
@port = 3000
|
@port = 3000
|
||||||
@env = ENV["KEMAL_ENV"]? || "development"
|
@env = ENV["KEMAL_ENV"]? || "development"
|
||||||
|
|
Loading…
Reference in a new issue