refactor(shutdown): extract 4 identical Ctrl+C handlers into core/shutdown.rs

This commit is contained in:
teernisse
2026-03-06 13:40:44 -05:00
parent ac5602e565
commit 3a4fc96558
4 changed files with 2016 additions and 3339 deletions

1998
src/app/handlers.rs Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -4,26 +4,16 @@ pub mod config;
pub mod cron;
pub mod cursor;
pub mod db;
pub mod dependent_queue;
pub mod error;
pub mod events_db;
pub mod file_history;
pub mod lock;
pub mod logging;
pub mod metrics;
pub mod note_parser;
pub mod path_resolver;
pub mod paths;
pub mod payloads;
pub mod project;
pub mod references;
pub mod shutdown;
pub mod sync_run;
pub mod time;
pub mod timeline;
pub mod timeline_collect;
pub mod timeline_expand;
pub mod timeline_seed;
pub mod trace;
pub use config::Config;

View File

@@ -1,6 +1,20 @@
use std::sync::Arc;
use std::sync::atomic::{AtomicBool, Ordering};
/// Spawn a background task that listens for Ctrl+C.
///
/// First press: cancels `signal` and prints an interrupt message.
/// Second press: force-exits with code 130.
pub fn install_ctrl_c_handler(signal: ShutdownSignal) {
tokio::spawn(async move {
let _ = tokio::signal::ctrl_c().await;
eprintln!("\nInterrupted, finishing current batch... (Ctrl+C again to force quit)");
signal.cancel();
let _ = tokio::signal::ctrl_c().await;
std::process::exit(130);
});
}
/// A cooperative cancellation token for graceful shutdown.
///
/// Clone-able and cheaply checkable from any thread or async task.

File diff suppressed because it is too large Load Diff