This repository has been archived by the owner on Oct 2, 2019. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Move signal handling to its own class
- Loading branch information
1 parent
a5763a5
commit 6e91312
Showing
2 changed files
with
21 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
require "socket" | ||
require "../logger" | ||
|
||
module BoJack | ||
module EventLoop | ||
class Signal | ||
@logger : BoJack::Logger = BoJack::Logger.instance | ||
|
||
def watch(server : TCPServer) | ||
::Signal::INT.trap do | ||
@logger.info("BoJack is going to take a rest") | ||
|
||
server.close | ||
|
||
exit | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters