mirror of
https://github.com/uqbar-dao/nectar.git
synced 2025-01-02 05:28:22 +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;
|
||||
}
|
||||
},
|
||||
ne = network_error_recv.recv() => {
|
||||
let wrapped_network_error = ne.expect("fatal: networking module died");
|
||||
Some(wrapped_network_error) = network_error_recv.recv() => {
|
||||
let _ = send_to_terminal.send(
|
||||
t::Printout {
|
||||
verbosity: 1,
|
||||
|
27
src/main.rs
27
src/main.rs
@ -315,22 +315,13 @@ async fn main() {
|
||||
encryptor_receiver,
|
||||
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! {
|
||||
Some(res) = tasks.join_next() => {
|
||||
if let Err(e) = res {
|
||||
format!("what does this mean? {:?}", e)
|
||||
} else if let Ok(Err(e)) = 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?
|
||||
}
|
||||
Some(Ok(res)) = tasks.join_next() => {
|
||||
format!(
|
||||
"\x1b[38;5;196muh oh, a kernel process crashed -- this should never happen: {:?}\x1b[0m",
|
||||
res
|
||||
)
|
||||
}
|
||||
quit = terminal::terminal(
|
||||
our.clone(),
|
||||
@ -347,10 +338,10 @@ async fn main() {
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// shutdown signal to fs for flush
|
||||
let _ = fs_kill_send.send(());
|
||||
let _ = fs_kill_confirm_recv.await;
|
||||
// println!("fs shutdown complete.");
|
||||
|
||||
// gracefully abort all running processes in kernel
|
||||
let _ = kernel_message_sender
|
||||
@ -375,10 +366,10 @@ async fn main() {
|
||||
signed_capabilities: None,
|
||||
})
|
||||
.await;
|
||||
|
||||
// abort all remaining tasks
|
||||
tasks.shutdown().await;
|
||||
let _ = crossterm::terminal::disable_raw_mode();
|
||||
println!();
|
||||
println!("\x1b[38;5;196m{}\x1b[0m", quit_msg);
|
||||
println!("\r\n\x1b[38;5;196m{}\x1b[0m", quit_msg);
|
||||
return;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user