mirror of
https://github.com/tun2proxy/tun2proxy.git
synced 2025-04-24 07:46:03 +00:00
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
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:
parent
7657f1603f
commit
0ccfa4a0e2
1 changed files with 7 additions and 0 deletions
|
@ -37,6 +37,7 @@ async fn main_async(args: Args) -> Result<(), BoxError> {
|
||||||
|
|
||||||
let shutdown_token = tokio_util::sync::CancellationToken::new();
|
let shutdown_token = tokio_util::sync::CancellationToken::new();
|
||||||
let main_loop_handle = tokio::spawn({
|
let main_loop_handle = tokio::spawn({
|
||||||
|
let args = args.clone();
|
||||||
let shutdown_token = shutdown_token.clone();
|
let shutdown_token = shutdown_token.clone();
|
||||||
async move {
|
async move {
|
||||||
#[cfg(target_os = "linux")]
|
#[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())?;
|
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(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue