From 9682ba2424d7034a1afa8f7fe329d95a19226b34 Mon Sep 17 00:00:00 2001 From: Astro Date: Thu, 3 Nov 2022 16:50:08 +0100 Subject: [PATCH] main: exit on panic --- src/main.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main.rs b/src/main.rs index 271046e..6a9f847 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,5 @@ use std::time::Duration; +use std::{panic, process}; use tokio::time::timeout; mod config; @@ -11,6 +12,13 @@ use worker::Message; #[tokio::main] async fn main() { + let orig_hook = panic::take_hook(); + panic::set_hook(Box::new(move |panic_info| { + // invoke the default handler and exit the process + orig_hook(panic_info); + process::exit(1); + })); + let config = config::Config::load_file( &std::env::args() .skip(1)