mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-01-29 00:35:38 +08:00
refactor: service reinstallation logic on detection failure
This commit is contained in:
@@ -141,15 +141,17 @@ impl CoreManager {
|
||||
|
||||
let config_path = Config::generate_file(ConfigType::Run)?;
|
||||
|
||||
// 先尝试服务模式
|
||||
if service::check_service().await.is_ok() {
|
||||
// 先检查服务状态
|
||||
let service_available = service::check_service().await.is_ok();
|
||||
|
||||
if service_available {
|
||||
log::info!(target: "app", "try to run core in service mode");
|
||||
match service::run_core_by_service(&config_path).await {
|
||||
Ok(_) => {
|
||||
log::info!(target: "app", "core started successfully in service mode");
|
||||
}
|
||||
Err(err) => {
|
||||
// 服务启动失败,尝试sidecar模式
|
||||
// 服务启动失败,直接尝试sidecar模式,不再尝试重装服务
|
||||
log::warn!(target: "app", "failed to start core in service mode: {}", err);
|
||||
log::info!(target: "app", "trying to run core in sidecar mode");
|
||||
self.run_core_by_sidecar(&config_path).await?;
|
||||
@@ -308,6 +310,19 @@ impl CoreManager {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// 强制重新安装服务(供UI调用,用户主动修复服务)
|
||||
pub async fn repair_service(&self) -> Result<()> {
|
||||
log::info!(target: "app", "user requested service repair");
|
||||
|
||||
// 调用强制重装服务
|
||||
service::force_reinstall_service().await?;
|
||||
|
||||
// 重启核心
|
||||
self.restart_core().await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// 使用默认配置
|
||||
pub async fn use_default_config(&self, msg_type: &str, msg_content: &str) -> Result<()> {
|
||||
let runtime_path = dirs::app_home_dir()?.join(RUNTIME_CONFIG);
|
||||
|
||||
Reference in New Issue
Block a user