Skip to content

Commit

Permalink
Merge pull request #59 from sksat/exit-on-thread-panic
Browse files Browse the repository at this point in the history
Exit process on panic in thread for restart container
  • Loading branch information
sksat authored Oct 26, 2022
2 parents 67a412d + 056252a commit c45691d
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ async fn main() -> Result<(), Box<dyn Error>> {
// install global collector configured based on RUST_LOG env var.
tracing_subscriber::fmt::init();

// cause process exit on panic in thread for restart container
let orig_hook = std::panic::take_hook();
std::panic::set_hook(Box::new(move |panic_info| {
orig_hook(panic_info);
std::process::exit(1);
}));

let opt = Opt::from_args();

info!("start app");
Expand Down

0 comments on commit c45691d

Please sign in to comment.