mirror of
https://github.com/jamiepine/voicebox.git
synced 2026-09-26 13:45:16 -07:00
Refactor Tauri server management and improve logging
- Updated the server management logic in main.rs to include the PID of the existing voicebox server when reusing it, enhancing clarity in logging. - Improved the formatting of imports in App.tsx for better readability.
This commit is contained in:
+7
-1
@@ -15,7 +15,13 @@ import { Toaster } from '@/components/ui/toaster';
|
|||||||
import { ProfileList } from '@/components/VoiceProfiles/ProfileList';
|
import { ProfileList } from '@/components/VoiceProfiles/ProfileList';
|
||||||
import { useModelDownloadToast } from '@/lib/hooks/useModelDownloadToast';
|
import { useModelDownloadToast } from '@/lib/hooks/useModelDownloadToast';
|
||||||
import { MODEL_DISPLAY_NAMES, useRestoreActiveTasks } from '@/lib/hooks/useRestoreActiveTasks';
|
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';
|
import { useServerStore } from '@/stores/serverStore';
|
||||||
|
|
||||||
// Track if server is starting to prevent duplicate starts
|
// Track if server is starting to prevent duplicate starts
|
||||||
|
|||||||
@@ -41,9 +41,14 @@ async fn start_server(
|
|||||||
let parts: Vec<&str> = line.split_whitespace().collect();
|
let parts: Vec<&str> = line.split_whitespace().collect();
|
||||||
if parts.len() >= 2 {
|
if parts.len() >= 2 {
|
||||||
let command = parts[0];
|
let command = parts[0];
|
||||||
|
let pid_str = parts[1];
|
||||||
if command.contains("voicebox") {
|
if command.contains("voicebox") {
|
||||||
println!("Found existing voicebox-server on port {}, reusing it", SERVER_PORT);
|
if let Ok(pid) = pid_str.parse::<u32>() {
|
||||||
return Ok(format!("http://127.0.0.1:{}", 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));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -68,7 +73,9 @@ async fn start_server(
|
|||||||
{
|
{
|
||||||
let tasklist_str = String::from_utf8_lossy(&tasklist_output.stdout);
|
let tasklist_str = String::from_utf8_lossy(&tasklist_output.stdout);
|
||||||
if tasklist_str.to_lowercase().contains("voicebox") {
|
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));
|
return Ok(format!("http://127.0.0.1:{}", SERVER_PORT));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user