From 0b07070237a568d96d1cfbaf7b6df0d0801dbeb5 Mon Sep 17 00:00:00 2001 From: Serdar Dogruyol Date: Wed, 4 Oct 2017 19:51:14 +0300 Subject: [PATCH] Don't initiliaze server if it's already initialized --- spec/route_handler_spec.cr | 1 - src/kemal.cr | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/spec/route_handler_spec.cr b/spec/route_handler_spec.cr index 8be01c0..f1a53bb 100644 --- a/spec/route_handler_spec.cr +++ b/spec/route_handler_spec.cr @@ -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 diff --git a/src/kemal.cr b/src/kemal.cr index 61e512f..3262341 100644 --- a/src/kemal.cr +++ b/src/kemal.cr @@ -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