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
|
|
@ -24,13 +24,17 @@ const KEEP_SECS: i64 = 7 * 24 * 3600;
|
|||
/// the vacuum SQL against its events.sqlite if present. Errors are
|
||||
/// logged but don't tear the loop down.
|
||||
pub fn spawn(coord: Arc<Coordinator>) {
|
||||
let mut shutdown = coord.shutdown_rx();
|
||||
tokio::spawn(async move {
|
||||
loop {
|
||||
sweep_once();
|
||||
// touching coord keeps the type wired in case future sweeps
|
||||
// need approvals/etc.; the ref is otherwise unused today.
|
||||
let _ = &coord;
|
||||
tokio::time::sleep(VACUUM_INTERVAL).await;
|
||||
tokio::select! {
|
||||
_ = tokio::time::sleep(VACUUM_INTERVAL) => {}
|
||||
_ = shutdown.changed() => {
|
||||
tracing::info!("events vacuum: shutdown signal received");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue