earlier check for stop signal

This commit is contained in:
Jörn-Michael Miehe 2025-06-05 12:58:09 +00:00
parent e86b11d058
commit 3bf5d96e04

View file

@ -25,7 +25,7 @@ fn main() {
let stop_ctrlc = stop.clone();
ctrlc::set_handler(move || {
stop_ctrlc.store(true, Ordering::SeqCst);
info!("stopping after chunk ...");
info!("stopping as soon as possible ...");
})
.expect("Error setting Ctrl-C handler");
@ -48,7 +48,10 @@ fn main() {
.interact()
.map_or(None, |b| b.then_some(state))
})
.unwrap_or_else(|| match AppState::from_args(&args, &agent) {
.unwrap_or_else(|| {
stop.load(Ordering::SeqCst).then(|| exit(0));
match AppState::from_args(&args, &agent) {
Ok(state) => {
state.save().unwrap();
state
@ -72,6 +75,7 @@ fn main() {
exit(1);
}
}
});
info!("continuing with state: {state:?}");