-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Signal/Interrupt package #1392
Signal/Interrupt package #1392
Conversation
One question I have is whether we even need |
I added two commits that impl the |
535b728
to
a8d43a6
Compare
a8d43a6
to
d907b63
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! We'll be able to use this in a few other projects we have in mind.
One question: what's the rationale behind removing the interrupt handlers in favor of using regular defers everywhere?
signal/signal.go
Outdated
@@ -12,33 +12,30 @@ import ( | |||
|
|||
var ( | |||
// interruptChannel is used to receive SIGINT (Ctrl+C) signals. | |||
interruptChannel chan os.Signal | |||
interruptChannel = make(chan os.Signal, 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice addition! Should've been this way all along.
Rationale for using defer: the current system executes FIFO order, which is fine since only two functions are registered (one of which is composite, and for the most part, executes |
can squash the last two commits if rationale is sound |
👍 |
d907b63
to
97aa5c1
Compare
squashed commits and rebased on master |
97aa5c1
to
5144df6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 💫
Moves most of the contents in
signal.go
into it's own package namedsignal
. This is done in preparation of having standalone watchtowers, so each daemon can share this code.Notable changes:
defer
. The handlers inlnd.go
have now been separated, and are registered after eachStart()
.func() error
instead offunc()
. All of the handlers we use are of this type, so it makes it cleaner even though we don't handle the errors during an interrupt.