From 3219230a065907c1cfba3f15e01888f1f8bec04b Mon Sep 17 00:00:00 2001 From: "shicai.xu" Date: Tue, 24 Dec 2024 23:24:13 +0800 Subject: [PATCH] fix stack backtrace missing when panic happens --- dt-main/src/main.rs | 4 +++- dt-task/src/task_runner.rs | 2 -- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dt-main/src/main.rs b/dt-main/src/main.rs index 7a293a57..b3cf1074 100644 --- a/dt-main/src/main.rs +++ b/dt-main/src/main.rs @@ -1,10 +1,12 @@ -use std::env; +use std::{env, panic}; use dt_precheck::{config::task_config::PrecheckTaskConfig, do_precheck}; use dt_task::task_runner::TaskRunner; #[tokio::main] async fn main() { + env::set_var("RUST_BACKTRACE", "1"); + let args: Vec = env::args().collect(); if args.len() < 2 { panic!("no task_config provided in args"); diff --git a/dt-task/src/task_runner.rs b/dt-task/src/task_runner.rs index 29adcc51..41c39200 100644 --- a/dt-task/src/task_runner.rs +++ b/dt-task/src/task_runner.rs @@ -1,5 +1,4 @@ use std::{ - env, fs::{self, File}, io::Read, panic, @@ -74,7 +73,6 @@ impl TaskRunner { self.init_log4rs()?; } - env::set_var("RUST_BACKTRACE", "1"); panic::set_hook(Box::new(|panic_info| { log_error!("panic: {}", panic_info); }));