earlier check for stop signal
This commit is contained in:
parent
e86b11d058
commit
3bf5d96e04
1 changed files with 27 additions and 23 deletions
|
|
@ -25,7 +25,7 @@ fn main() {
|
||||||
let stop_ctrlc = stop.clone();
|
let stop_ctrlc = stop.clone();
|
||||||
ctrlc::set_handler(move || {
|
ctrlc::set_handler(move || {
|
||||||
stop_ctrlc.store(true, Ordering::SeqCst);
|
stop_ctrlc.store(true, Ordering::SeqCst);
|
||||||
info!("stopping after chunk ...");
|
info!("stopping as soon as possible ...");
|
||||||
})
|
})
|
||||||
.expect("Error setting Ctrl-C handler");
|
.expect("Error setting Ctrl-C handler");
|
||||||
|
|
||||||
|
|
@ -48,7 +48,10 @@ fn main() {
|
||||||
.interact()
|
.interact()
|
||||||
.map_or(None, |b| b.then_some(state))
|
.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) => {
|
Ok(state) => {
|
||||||
state.save().unwrap();
|
state.save().unwrap();
|
||||||
state
|
state
|
||||||
|
|
@ -72,6 +75,7 @@ fn main() {
|
||||||
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
info!("continuing with state: {state:?}");
|
info!("continuing with state: {state:?}");
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue