tauri-app: spawn record-daemon on startup if not present
record-daemon / Build, check and test (push) Successful in 2m14s
record-daemon / Build, check and test (push) Successful in 2m14s
This commit is contained in:
@@ -395,6 +395,28 @@ fn get_video_metadata(video_path: String) -> Result<Value, String> {
|
||||
pub fn run() {
|
||||
tauri::Builder::default()
|
||||
.plugin(tauri_plugin_opener::init())
|
||||
.setup(|app| {
|
||||
// Auto-start the record-daemon on app launch.
|
||||
// We spawn a background task so the UI isn't blocked while the
|
||||
// daemon boots (it can take a few seconds to initialise OBS).
|
||||
let handle = app.handle().clone();
|
||||
tauri::async_runtime::spawn(async move {
|
||||
match daemon_ipc::ensure_daemon_running(30).await {
|
||||
Ok(true) => {
|
||||
eprintln!("[tauri] record-daemon is running");
|
||||
}
|
||||
Ok(false) => {
|
||||
eprintln!("[tauri] record-daemon did not become ready within the timeout");
|
||||
}
|
||||
Err(e) => {
|
||||
eprintln!("[tauri] failed to start record-daemon: {}", e);
|
||||
}
|
||||
}
|
||||
// Drop the handle – no further use
|
||||
drop(handle);
|
||||
});
|
||||
Ok(())
|
||||
})
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
get_game_history,
|
||||
get_timeline,
|
||||
@@ -408,6 +430,7 @@ pub fn run() {
|
||||
get_video_metadata,
|
||||
// Daemon IPC commands
|
||||
daemon_ipc::daemon_is_running,
|
||||
daemon_ipc::daemon_ensure_running,
|
||||
daemon_ipc::daemon_get_status,
|
||||
daemon_ipc::daemon_get_settings,
|
||||
daemon_ipc::daemon_update_settings,
|
||||
|
||||
Reference in New Issue
Block a user