mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-04-16 23:40:32 +08:00
fix(server): spawn embedded server commands using AsyncHandler on Linux to prevent new app instance creation
This commit is contained in:
parent
4a9a4ab6e1
commit
509a45bd1e
@ -101,6 +101,17 @@ pub fn embed_server() {
|
|||||||
|
|
||||||
let commands = visible.or(scheme).or(pac);
|
let commands = visible.or(scheme).or(pac);
|
||||||
|
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
{
|
||||||
|
// On Linux, spawing through a new tokio runtime cause to create a new app instance
|
||||||
|
// So we have to spawn through AsyncHandler(tauri::async_runtime) to avoid that
|
||||||
|
// See relate comments in https://github.com/clash-verge-rev/clash-verge-rev/pull/5908#issuecomment-3678727040
|
||||||
|
AsyncHandler::spawn(move || async move {
|
||||||
|
run(commands, port, shutdown_rx).await;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(not(target_os = "linux"))]
|
||||||
if let Ok(rt) = tokio::runtime::Builder::new_current_thread()
|
if let Ok(rt) = tokio::runtime::Builder::new_current_thread()
|
||||||
.thread_name("clash-verge-rev-embed-server")
|
.thread_name("clash-verge-rev-embed-server")
|
||||||
.worker_threads(1)
|
.worker_threads(1)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user