feat: macos service installation query, can't avoid it, add service run check, if installation not confirmed, exit automatically after 10 seconds

This commit is contained in:
huzibaca 2024-10-27 06:32:25 +08:00
parent df3c296850
commit 4ce7d9f7a9
No known key found for this signature in database
GPG Key ID: D4364EE4851DC302

View File

@ -57,7 +57,25 @@ pub async fn resolve_setup(app: &mut App) {
match service::reinstall_service().await {
Ok(_) => {
log::info!(target:"app", "install service susccess.");
#[cfg(not(target_os = "macos"))]
std::thread::sleep(std::time::Duration::from_millis(1000));
#[cfg(target_os = "macos")]
{
let mut service_runing = false;
for _ in 0..20 {
if service::check_service().await.is_ok() {
service_runing = true;
break;
} else {
log::warn!(target: "app", "service not runing, sleep 500ms and check again.");
std::thread::sleep(std::time::Duration::from_millis(500));
}
}
if !service_runing {
log::error!(target: "app", "service not runing. exit");
app.app_handle().exit(-2);
}
}
}
Err(e) => {
log::error!(target: "app", "{e:?}");