-
Notifications
You must be signed in to change notification settings - Fork 24
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
main: handle termination signals #152
Conversation
So that we can log some of the initial errors instead of printing them.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #152 +/- ##
======================================
Coverage 0.00% 0.00%
======================================
Files 1 1
Lines 105 126 +21
======================================
- Misses 105 126 +21 ☔ View full report in Codecov by Sentry. |
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.
tACK
Want to note that since you already use |
@tnull Good point, thank you! |
dd9e22a
to
f94892c
Compare
let mut sigterm_stream = tokio::signal::unix::signal(SignalKind::terminate()) | ||
.map_err(|e| error!("Error initializing sigterm signal: {e}."))?; | ||
let mut sigint_stream = tokio::signal::unix::signal(SignalKind::interrupt()) | ||
.map_err(|e| error!("Error initializing sigint signal: {e}."))?; | ||
|
||
tokio::spawn(async move { | ||
tokio::select! { | ||
_ = sigint_stream.recv() => { | ||
info!("Received CTRL-C, shutting down.."); | ||
shutdown.trigger(); | ||
} | ||
_ = sigterm_stream.recv() => { | ||
info!("Received SIGTERM, shutting down.."); | ||
shutdown.trigger(); | ||
} | ||
} | ||
}); |
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.
Maybe we can add an issue to get integration tests for this up? I can look into it then.
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.
I had actually already gotten pretty far into writing a basic integration test for this, before realizing it was probably too big for this PR heh. I'll either put it up as a draft or finish it off. But I have some further integration test ideas I'll post as issues today, if you happen to be interested.
This PR fixes #150 with the following:
signal
feature to process SIGTERM and SIGINT signals, tying them to thetriggered
LifecycleSignals we had in place already.serve_with_shutdown
tonic so the server shuts down more gracefully. Maybe it'd be worth looking to see if we can do more for a graceful shutdown later on. With this change, the server seems to work normally. But I'm realizing we don't have any quick integration tests of the server in place. This doesn't necessarily need to go in this PR... but if I have time I'll add something quick.