From af130cf56edaa81b081cd96a5158ec8856a8721f Mon Sep 17 00:00:00 2001 From: soruh Date: Sat, 18 Mar 2023 14:46:55 +0100 Subject: [PATCH] make whole programm exit on worker thread crash --- src/main.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 7950768..55c5b77 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,3 @@ -// #![allow(unused)] - use std::{ fmt::Debug, fs::File, @@ -93,6 +91,13 @@ impl Config { #[tokio::main] async fn main() -> anyhow::Result<()> { + // make whole programm exit on worker thread crash + let default_panic = std::panic::take_hook(); + std::panic::set_hook(Box::new(move |info| { + default_panic(info); + std::process::exit(1); + })); + let config = Arc::new(Config::load("config.json")?); if config.allowed_ports.is_empty() {