mirror of
https://github.com/uqbar-dao/nectar.git
synced 2025-01-04 15:53:21 +03:00
hotfix: graceful shutdown
This commit is contained in:
parent
111d3d15fa
commit
00ae78b04c
@ -1946,8 +1946,7 @@ async fn make_event_loop(
|
|||||||
is_debug = !is_debug;
|
is_debug = !is_debug;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
ne = network_error_recv.recv() => {
|
Some(wrapped_network_error) = network_error_recv.recv() => {
|
||||||
let wrapped_network_error = ne.expect("fatal: networking module died");
|
|
||||||
let _ = send_to_terminal.send(
|
let _ = send_to_terminal.send(
|
||||||
t::Printout {
|
t::Printout {
|
||||||
verbosity: 1,
|
verbosity: 1,
|
||||||
|
27
src/main.rs
27
src/main.rs
@ -315,22 +315,13 @@ async fn main() {
|
|||||||
encryptor_receiver,
|
encryptor_receiver,
|
||||||
print_sender.clone(),
|
print_sender.clone(),
|
||||||
));
|
));
|
||||||
// if a runtime task exits, try to recover it,
|
|
||||||
// unless it was terminal signaling a quit
|
|
||||||
let quit_msg: String = tokio::select! {
|
let quit_msg: String = tokio::select! {
|
||||||
Some(res) = tasks.join_next() => {
|
Some(Ok(res)) = tasks.join_next() => {
|
||||||
if let Err(e) = res {
|
format!(
|
||||||
format!("what does this mean? {:?}", e)
|
"\x1b[38;5;196muh oh, a kernel process crashed -- this should never happen: {:?}\x1b[0m",
|
||||||
} else if let Ok(Err(e)) = res {
|
res
|
||||||
format!(
|
)
|
||||||
"\x1b[38;5;196muh oh, a kernel process crashed: {}\x1b[0m",
|
|
||||||
e
|
|
||||||
)
|
|
||||||
// TODO restart the task?
|
|
||||||
} else {
|
|
||||||
"what does this mean???".to_string()
|
|
||||||
// TODO restart the task?
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
quit = terminal::terminal(
|
quit = terminal::terminal(
|
||||||
our.clone(),
|
our.clone(),
|
||||||
@ -347,10 +338,10 @@ async fn main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// shutdown signal to fs for flush
|
// shutdown signal to fs for flush
|
||||||
let _ = fs_kill_send.send(());
|
let _ = fs_kill_send.send(());
|
||||||
let _ = fs_kill_confirm_recv.await;
|
let _ = fs_kill_confirm_recv.await;
|
||||||
// println!("fs shutdown complete.");
|
|
||||||
|
|
||||||
// gracefully abort all running processes in kernel
|
// gracefully abort all running processes in kernel
|
||||||
let _ = kernel_message_sender
|
let _ = kernel_message_sender
|
||||||
@ -375,10 +366,10 @@ async fn main() {
|
|||||||
signed_capabilities: None,
|
signed_capabilities: None,
|
||||||
})
|
})
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
// abort all remaining tasks
|
// abort all remaining tasks
|
||||||
tasks.shutdown().await;
|
tasks.shutdown().await;
|
||||||
let _ = crossterm::terminal::disable_raw_mode();
|
let _ = crossterm::terminal::disable_raw_mode();
|
||||||
println!();
|
println!("\r\n\x1b[38;5;196m{}\x1b[0m", quit_msg);
|
||||||
println!("\x1b[38;5;196m{}\x1b[0m", quit_msg);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user