Skip to content

Commit

Permalink
Move signal trapping to Kemal::Application
Browse files Browse the repository at this point in the history
  • Loading branch information
straight-shoota authored and sdogruyol committed Dec 17, 2018
1 parent e6dc494 commit 5f1ce1e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
8 changes: 7 additions & 1 deletion src/kemal/application.cr
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,14 @@ class Kemal::Application < Kemal::Base
end
end

# Test environment doesn't need to have signal trap, built-in images, and logging.
# Test environment doesn't need to have signal trap and built-in images.
unless @config.env == "test"
Signal::INT.trap do
log "Kemal is going to take a rest!" if @config.shutdown_message?
stop if running?
exit
end

# This route serves the built-in images for not_found and exceptions.
self.get "/__kemal__/:image" do |env|
image = env.params.url["image"]
Expand Down
7 changes: 0 additions & 7 deletions src/kemal/base.cr
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,6 @@ class Kemal::Base
end

private def prepare_for_server_start
unless @config.env == "test"
Signal::INT.trap do
log "Kemal is going to take a rest!" if @config.shutdown_message?
stop if running?
exit
end
end
end

private def start_server(port)
Expand Down

0 comments on commit 5f1ce1e

Please sign in to comment.