mirror of
https://github.com/jamiepine/voicebox.git
synced 2026-09-18 22:30:40 -07:00
fix: reliably keep server alive after GUI close on Windows (#402)
The HTTP /watchdog/disable request races with process exit on Windows, causing the watchdog to kill the server before the request arrives. Added a .keep-running sentinel file as a reliable fallback: - Tauri writes the file to data_dir before sending the HTTP request - The watchdog checks for it during the grace period after detecting parent death - The file is removed after being read to avoid stale state This approach works regardless of HTTP timing because file writes complete synchronously before the Tauri process exits. Fixes #372 Co-authored-by: Matt Van Horn <[email protected]>
This commit is contained in:
co-authored by
Matt Van Horn
parent
3e7727d1d2
commit
479bc7fc5e
@@ -860,6 +860,22 @@ pub fn run() {
|
||||
// Tell the server to disable its watchdog so it survives
|
||||
// after this process exits.
|
||||
println!("Keep server running: disabling watchdog...");
|
||||
|
||||
// Write a sentinel file as a reliable fallback. On Windows
|
||||
// the HTTP request below can race with process exit, leaving
|
||||
// the watchdog unaware it should stay alive. The sentinel
|
||||
// file is checked during the watchdog grace period.
|
||||
let data_dir = app
|
||||
.path()
|
||||
.app_data_dir()
|
||||
.unwrap_or_default();
|
||||
let sentinel = data_dir.join(".keep-running");
|
||||
if let Err(e) = std::fs::write(&sentinel, b"1") {
|
||||
eprintln!("Failed to write keep-running sentinel: {}", e);
|
||||
} else {
|
||||
println!("Wrote keep-running sentinel to {:?}", sentinel);
|
||||
}
|
||||
|
||||
let client = reqwest::blocking::Client::builder()
|
||||
.timeout(std::time::Duration::from_secs(2))
|
||||
.build()
|
||||
|
||||
Reference in New Issue
Block a user