-
Notifications
You must be signed in to change notification settings - Fork 91
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
feat(server): abort on panic #4026
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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
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
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
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
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 |
---|---|---|
|
@@ -4,6 +4,7 @@ use relay_config::Config; | |
use relay_system::{Addr, AsyncResponse, Controller, FromMessage, Interface, Sender, Service}; | ||
use std::future::Future; | ||
use tokio::sync::watch; | ||
use tokio::task::JoinHandle; | ||
use tokio::time::{timeout, Instant}; | ||
|
||
use crate::services::metrics::RouterHandle; | ||
|
@@ -189,13 +190,13 @@ impl HealthCheckService { | |
impl Service for HealthCheckService { | ||
type Interface = HealthCheck; | ||
|
||
fn spawn_handler(mut self, mut rx: relay_system::Receiver<Self::Interface>) { | ||
fn spawn_handler(mut self, mut rx: relay_system::Receiver<Self::Interface>) -> JoinHandle<()> { | ||
let (update_tx, update_rx) = watch::channel(StatusUpdate::new(Status::Unhealthy)); | ||
let check_interval = self.config.health_refresh_interval(); | ||
// Add 10% buffer to the internal timeouts to avoid race conditions. | ||
let status_timeout = (check_interval + self.config.health_probe_timeout()).mul_f64(1.1); | ||
|
||
tokio::spawn(async move { | ||
let j1 = tokio::spawn(async move { | ||
let shutdown = Controller::shutdown_handle(); | ||
|
||
while shutdown.get().is_none() { | ||
|
@@ -212,7 +213,7 @@ impl Service for HealthCheckService { | |
update_tx.send(StatusUpdate::new(Status::Unhealthy)).ok(); | ||
}); | ||
|
||
tokio::spawn(async move { | ||
let _j2 = tokio::spawn(async move { | ||
while let Some(HealthCheck(message, sender)) = rx.recv().await { | ||
let update = update_rx.borrow(); | ||
|
||
|
@@ -225,6 +226,8 @@ impl Service for HealthCheckService { | |
}); | ||
} | ||
}); | ||
|
||
j1 // TODO: should return j1 + j2 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We have a few places where the spawn handler spawns more than one task. In a follow-up, we should transform these to something like tokio::spawn(async {
let subtask = tokio::spawn(async {...});
/// ...
subtask.await;
}); |
||
} | ||
} | ||
|
||
|
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
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Note: when every service implements a shutdown listener, awaiting on
finished
becomes unnecessary: We can simply await on all thejoin_handles
and guarantee that every service finished its main task.