Add Kemal.stop. Fixes #269

This commit is contained in:
Sdogruyol 2016-12-08 13:50:54 +03:00
parent 166fb96f34
commit 9c1c832c9a
2 changed files with 18 additions and 2 deletions

View file

@ -30,7 +30,7 @@ module Kemal
unless config.env == "test"
Signal::INT.trap {
log "Kemal is going to take a rest!\n"
config.server.close
Kemal.stop
exit
}
@ -46,7 +46,22 @@ module Kemal
end
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
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