mirror of
https://gitea.invidious.io/iv-org/shard-kemal.git
synced 2024-08-15 00:53:36 +00:00
Add Kemal.stop. Fixes #269
This commit is contained in:
parent
166fb96f34
commit
9c1c832c9a
2 changed files with 18 additions and 2 deletions
17
src/kemal.cr
17
src/kemal.cr
|
@ -30,7 +30,7 @@ module Kemal
|
||||||
unless config.env == "test"
|
unless config.env == "test"
|
||||||
Signal::INT.trap {
|
Signal::INT.trap {
|
||||||
log "Kemal is going to take a rest!\n"
|
log "Kemal is going to take a rest!\n"
|
||||||
config.server.close
|
Kemal.stop
|
||||||
exit
|
exit
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +46,22 @@ module Kemal
|
||||||
end
|
end
|
||||||
|
|
||||||
log "[#{config.env}] Kemal is ready to lead at #{config.scheme}://#{config.host_binding}:#{config.port}\n"
|
log "[#{config.env}] Kemal is ready to lead at #{config.scheme}://#{config.host_binding}:#{config.port}\n"
|
||||||
|
config.running = true
|
||||||
|
pp config.running
|
||||||
config.server.listen
|
config.server.listen
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.stop
|
||||||
|
if config.running
|
||||||
|
if config.server
|
||||||
|
config.server.close
|
||||||
|
config.running = false
|
||||||
|
else
|
||||||
|
raise "config.server is not set. Please use Kemal.run to set the server."
|
||||||
|
end
|
||||||
|
else
|
||||||
|
raise "Kemal is already stopped."
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -14,7 +14,7 @@ module Kemal
|
||||||
@ssl : OpenSSL::SSL::Context::Server?
|
@ssl : OpenSSL::SSL::Context::Server?
|
||||||
{% end %}
|
{% end %}
|
||||||
|
|
||||||
property host_binding, ssl, port, env, public_folder, logging,
|
property host_binding, ssl, port, env, public_folder, logging, running,
|
||||||
always_rescue, serve_static : (Bool | Hash(String, Bool)), server, session : Hash(String, Time::Span | String), extra_options
|
always_rescue, serve_static : (Bool | Hash(String, Bool)), server, session : Hash(String, Time::Span | String), extra_options
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
|
@ -32,6 +32,7 @@ module Kemal
|
||||||
@router_included = false
|
@router_included = false
|
||||||
@custom_handler_position = 4
|
@custom_handler_position = 4
|
||||||
@default_handlers_setup = false
|
@default_handlers_setup = false
|
||||||
|
@running = false
|
||||||
end
|
end
|
||||||
|
|
||||||
def logger
|
def logger
|
||||||
|
|
Loading…
Reference in a new issue