add graceful shutdown signal to coordinator and all background tasks
This commit is contained in:
parent
67b47872e0
commit
e27984b74c
6 changed files with 86 additions and 12 deletions
|
|
@ -26,6 +26,7 @@ use crate::lifecycle::{self, AGENT_PREFIX, MANAGER_NAME};
|
|||
const POLL_INTERVAL: Duration = Duration::from_secs(10);
|
||||
|
||||
pub fn spawn(coord: Arc<Coordinator>) {
|
||||
let mut shutdown = coord.shutdown_rx();
|
||||
tokio::spawn(async move {
|
||||
let mut prev_running: HashSet<String> = HashSet::new();
|
||||
let mut prev_logged_in: HashSet<String> = HashSet::new();
|
||||
|
|
@ -80,7 +81,13 @@ pub fn spawn(coord: Arc<Coordinator>) {
|
|||
prev_updated = current_updated;
|
||||
seeded = true;
|
||||
|
||||
tokio::time::sleep(POLL_INTERVAL).await;
|
||||
tokio::select! {
|
||||
_ = tokio::time::sleep(POLL_INTERVAL) => {}
|
||||
_ = shutdown.changed() => {
|
||||
tracing::info!("crash watcher: shutdown signal received");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue