force exit process while fatal error
Some checks are pending
Push or PR / Check semver (push) Waiting to run
Push or PR / build_n_test (macos-latest) (push) Waiting to run
Push or PR / build_n_test (ubuntu-latest) (push) Waiting to run
Push or PR / build_n_test (windows-latest) (push) Waiting to run
Push or PR / build_n_test_android (push) Waiting to run
Push or PR / build_n_test_ios (push) Waiting to run
Integration Tests / Proxy Tests (push) Waiting to run

This commit is contained in:
ssrlive 2025-04-18 11:03:05 +08:00
parent 7657f1603f
commit 0ccfa4a0e2

View file

@ -37,6 +37,7 @@ async fn main_async(args: Args) -> Result<(), BoxError> {
let shutdown_token = tokio_util::sync::CancellationToken::new();
let main_loop_handle = tokio::spawn({
let args = args.clone();
let shutdown_token = shutdown_token.clone();
async move {
#[cfg(target_os = "linux")]
@ -75,6 +76,12 @@ async fn main_async(args: Args) -> Result<(), BoxError> {
ctrlc_handel.await.map_err(|err| err.to_string())?;
}
if args.exit_on_fatal_error {
// Because `main_async` function perhaps stuck in `await` state, so we need to exit the process forcefully
log::info!("Exiting forcefully for internal fatal error...");
std::process::exit(1);
}
Ok(())
}