diff --git a/src-tauri/src/process_watcher.rs b/src-tauri/src/process_watcher.rs index 823bea471..09602cc4c 100644 --- a/src-tauri/src/process_watcher.rs +++ b/src-tauri/src/process_watcher.rs @@ -95,14 +95,10 @@ impl ProcessWatcher { _ = watch_timer.tick() => { let status_monitor3 = status_monitor2.clone(); - let exit_code = do_health_check(&mut child, status_monitor3, name.clone(), &mut uptime, expected_startup_time, health_timeout, app_shutdown.clone(), inner_shutdown.clone(), &mut warning_count).await?; + let exit_code = do_health_check(&mut child, status_monitor3, name.clone(), &mut uptime, expected_startup_time, health_timeout, app_shutdown.clone(), inner_shutdown.clone(), &mut warning_count, &stop_on_exit_codes).await?; if exit_code != 0 { - if stop_on_exit_codes.contains(&exit_code) { - return Ok(exit_code); - } - warn!(target: LOG_TARGET, "{} exited with error code: {}, restarting because it is not a listed exit code to list for", name, exit_code); - - } + return Ok(exit_code); + } // break; }, _ = inner_shutdown.wait() => { @@ -159,6 +155,7 @@ async fn do_health_check( app_shutdown: ShutdownSignal, inner_shutdown: ShutdownSignal, warning_count: &mut u32, + stop_on_exit_codes: &[i32], ) -> Result { let mut is_healthy = false; @@ -209,9 +206,12 @@ async fn do_health_check( match child.stop().await { Ok(exit_code) => { if exit_code != 0 { - error!(target: LOG_TARGET, "{} exited with error code: {}", name, exit_code); - // Do not restart on non-zero exit code. This will just keep happening. - return Ok(exit_code); + if stop_on_exit_codes.contains(&exit_code) { + return Ok(exit_code); + } + warn!(target: LOG_TARGET, "{} exited with error code: {}, restarting because it is not a listed exit code to list for", name, exit_code); + + // return Ok(exit_code); } else { info!(target: LOG_TARGET, "{} exited successfully", name); }