Skip to content

The open-source AI voice studio. Clone, dictate, create.

Refactor Tauri server management and improve logging

Jamie Pine48acc10422a9
diff --git a/app/src/App.tsx b/app/src/App.tsx
index 9c7e1a2f..d38c4109 100644
--- a/app/src/App.tsx
+++ b/app/src/App.tsx
@@ -15,7 +15,13 @@ import { Toaster } from '@/components/ui/toaster';
import { ProfileList } from '@/components/VoiceProfiles/ProfileList';
import { useModelDownloadToast } from '@/lib/hooks/useModelDownloadToast';
import { MODEL_DISPLAY_NAMES, useRestoreActiveTasks } from '@/lib/hooks/useRestoreActiveTasks';
-import { isMacOS, isTauri, setupWindowCloseHandler, startServer, setKeepServerRunning } from '@/lib/tauri';
+import {
+ isMacOS,
+ isTauri,
+ setKeepServerRunning,
+ setupWindowCloseHandler,
+ startServer,
+} from '@/lib/tauri';
import { useServerStore } from '@/stores/serverStore';
// Track if server is starting to prevent duplicate starts
diff --git a/tauri/src-tauri/src/main.rs b/tauri/src-tauri/src/main.rs
index 2dda00aa..b012c902 100644
--- a/tauri/src-tauri/src/main.rs
+++ b/tauri/src-tauri/src/main.rs
@@ -41,9 +41,14 @@ async fn start_server(
let parts: Vec<&str> = line.split_whitespace().collect();
if parts.len() >= 2 {
let command = parts[0];
+ let pid_str = parts[1];
if command.contains("voicebox") {
- println!("Found existing voicebox-server on port {}, reusing it", SERVER_PORT);
- return Ok(format!("http://127.0.0.1:{}", SERVER_PORT));
+ if let Ok(pid) = pid_str.parse::<u32>() {
+ println!("Found existing voicebox-server on port {} (PID: {}), reusing it", SERVER_PORT, pid);
+ // Store the PID so we can kill it on exit if needed
+ *state.server_pid.lock().unwrap() = Some(pid);
+ return Ok(format!("http://127.0.0.1:{}", SERVER_PORT));
+ }
}
}
}
@@ -68,7 +73,9 @@ async fn start_server(
{
let tasklist_str = String::from_utf8_lossy(&tasklist_output.stdout);
if tasklist_str.to_lowercase().contains("voicebox") {
- println!("Found existing voicebox-server on port {}, reusing it", SERVER_PORT);
+ println!("Found existing voicebox-server on port {} (PID: {}), reusing it", SERVER_PORT, pid);
+ // Store the PID so we can kill it on exit if needed
+ *state.server_pid.lock().unwrap() = Some(pid);
return Ok(format!("http://127.0.0.1:{}", SERVER_PORT));
}
}