add tokio console

This commit is contained in:
John Smith
2022-11-03 11:28:29 -04:00
parent f1bf883376
commit 404f579baa
10 changed files with 221 additions and 11 deletions

View File

@@ -91,8 +91,23 @@ fn main() -> EyreResult<()> {
}
// --- Normal Startup ---
let panic_on_shutdown = matches.occurrences_of("panic") != 0;
ctrlc::set_handler(move || {
shutdown();
if panic_on_shutdown {
let orig_hook = std::panic::take_hook();
std::panic::set_hook(Box::new(move |panic_info| {
// invoke the default handler and exit the process
orig_hook(panic_info);
let backtrace = backtrace::Backtrace::new();
eprintln!("Backtrace:\n{:?}", backtrace);
std::process::exit(1);
}));
panic!("panic requested");
} else {
shutdown();
}
})
.expect("Error setting Ctrl-C handler");