Don't initiliaze server if it's already initialized

This commit is contained in:
Serdar Dogruyol 2017-10-04 19:51:14 +03:00
parent ad692357d4
commit 0b07070237
2 changed files with 3 additions and 4 deletions

View file

@ -164,5 +164,4 @@ describe "Kemal::RouteHandler" do
client_response.status_code.should eq(302)
client_response.headers.has_key?("Location").should eq(true)
end
end

View file

@ -13,6 +13,7 @@ module Kemal
log "[#{config.env}] Kemal is ready to lead at #{config.scheme}://#{config.host_binding}:#{config.port}"
end
end
# Overload of self.run without port - fixex #399
def self.run
self.run(nil)
@ -58,11 +59,10 @@ module Kemal
end
end
server = HTTP::Server.new(config.host_binding, config.port, config.handlers)
config.server ||= HTTP::Server.new(config.host_binding, config.port, config.handlers)
{% if !flag?(:without_openssl) %}
server.tls = config.ssl
config.server.not_nil!.tls = config.ssl
{% end %}
config.server ||= server
config.running = true
yield config