Skip to content

Commit

Permalink
changes
Browse files Browse the repository at this point in the history
  • Loading branch information
neo773 committed Dec 23, 2024
1 parent 67e7240 commit 3e44332
Showing 1 changed file with 22 additions and 13 deletions.
35 changes: 22 additions & 13 deletions screenpipe-app-tauri/src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ use tauri::{
};
use tauri_plugin_autostart::MacosLauncher;
use tauri_plugin_autostart::ManagerExt;
use tauri_plugin_deep_link::DeepLinkExt;
#[allow(unused_imports)]
use tauri_plugin_shell::process::CommandEvent;
use tauri_plugin_store::StoreBuilder;
Expand Down Expand Up @@ -440,19 +439,29 @@ async fn main() {
let sidecar_manager_clone = sidecar_manager.clone();
app.manage(sidecar_manager.clone());

let sidecar_app_handle = app.handle().clone();
tauri::async_runtime::spawn(async move {
let mut manager = sidecar_manager_clone.lock().await;
if let Err(e) = manager.spawn(&sidecar_app_handle).await {
error!("Failed to spawn initial sidecar: {}", e);
}
let app_handle = app.handle().clone();

// Spawn a background task to check and restart periodically
let mut manager = sidecar_manager_clone.lock().await;
if let Err(e) = manager.check_and_restart(&sidecar_app_handle).await {
error!("Failed to restart sidecar: {}", e);
}
});
info!(
"will start sidecar: {}",
!use_dev_mode && !is_first_time_user
);

if !use_dev_mode && !is_first_time_user {
tauri::async_runtime::spawn(async move {
let mut manager = sidecar_manager_clone.lock().await;
if let Err(e) = manager.spawn(&app_handle).await {
error!("Failed to spawn initial sidecar: {}", e);
}

// Spawn a background task to check and restart periodically
let mut manager = sidecar_manager_clone.lock().await;
if let Err(e) = manager.check_and_restart(&app_handle).await {
error!("Failed to restart sidecar: {}", e);
}
});
} else {
debug!("Dev mode enabled, skipping sidecar spawn and restart");
}

// Inside the main function, after the `app.manage(port);` line, add:
let server_shutdown_tx = spawn_server(app.handle().clone(), 11435);
Expand Down

0 comments on commit 3e44332

Please sign in to comment.