Skip to content
Snippets Groups Projects
Unverified Commit 5098f14a authored by GyDi's avatar GyDi
Browse files

fix: service mode error and fallback to sidecar

parent a355a9c8
No related branches found
No related tags found
No related merge requests found
......@@ -107,16 +107,18 @@ impl CoreManager {
if enable {
// 服务模式启动失败就直接运行sidecar
match {
log::debug!(target: "app", "try to run core in service mode");
log::debug!(target: "app", "try to run core in service mode");
match (|| async {
win_service::check_service().await?;
win_service::run_core_by_service(&config_path).await
} {
})()
.await
{
Ok(_) => return Ok(()),
Err(err) => {
// 修改这个值,免得stop出错
*self.use_service_mode.lock() = false;
log::error!(target: "app", "{err}");
}
}
......@@ -141,7 +143,7 @@ impl CoreManager {
let (mut rx, cmd_child) = cmd.args(args).spawn()?;
// 将pid写入文件中
crate::log_err!({
crate::log_err!((|| {
let pid = cmd_child.pid();
let path = dirs::clash_pid_path()?;
fs::File::create(path)
......@@ -149,7 +151,7 @@ impl CoreManager {
.write(format!("{pid}").as_bytes())
.context("failed to write pid to the file")?;
<Result<()>>::Ok(())
});
})());
let mut sidecar = self.sidecar.lock();
*sidecar = Some(cmd_child);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment