Optimize startup logic contro

This commit is contained in:
chao wan 2024-10-25 12:03:28 +08:00
parent f1f3134058
commit d31c19b126

View File

@ -757,12 +757,20 @@ async fn main() {
rust_i18n::set_locale(&locale);
#[cfg(target_os = "windows")]
match windows_service::service_dispatcher::start(String::new(), ffi_service_main) {
Ok(_) => return,
Err(e) =>
{
use windows_service::service_dispatcher;
if let Ok(()) = service_dispatcher::start(String::new(), ffi_service_main) {
return;
let should_panic = if let windows_service::Error::Winapi(ref io_error) = e {
io_error.raw_os_error() != Some(0x427) // ERROR_FAILED_SERVICE_CONTROLLER_CONNECT
} else { true };
if should_panic {
panic!("SCM start an error: {}", e);
}
}
};
let cli = Cli::parse();
let cfg = TomlConfigLoader::from(cli);
init_logger(&cfg, false).unwrap();