add graceful shutdown signal to coordinator and all background tasks

This commit is contained in:
damocles 2026-05-20 13:05:13 +02:00
parent 67b47872e0
commit e27984b74c
6 changed files with 86 additions and 12 deletions

View file

@ -52,10 +52,17 @@ const REMINDER_BATCH_LIMIT: u64 = 100;
const POLL_INTERVAL: Duration = Duration::from_secs(5);
pub fn spawn(coord: Arc<Coordinator>) {
let mut shutdown = coord.shutdown_rx();
tokio::spawn(async move {
loop {
tick(&coord);
tokio::time::sleep(POLL_INTERVAL).await;
tokio::select! {
_ = tokio::time::sleep(POLL_INTERVAL) => {}
_ = shutdown.changed() => {
tracing::info!("reminder scheduler: shutdown signal received");
break;
}
}
}
});
}