Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

release-app update restart hack

Louis Beaumontac37666d9753
diff --git a/screenpipe-app-tauri/src-tauri/Cargo.toml b/screenpipe-app-tauri/src-tauri/Cargo.toml
index a7a0cee33..cf726f5e2 100644
--- a/screenpipe-app-tauri/src-tauri/Cargo.toml
+++ b/screenpipe-app-tauri/src-tauri/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "screenpipe-app"
-version = "0.32.14"
+version = "0.32.15"
description = ""
authors = ["you"]
license = ""
diff --git a/screenpipe-app-tauri/src-tauri/src/main.rs b/screenpipe-app-tauri/src-tauri/src/main.rs
index 87fa661c7..730f13312 100755
--- a/screenpipe-app-tauri/src-tauri/src/main.rs
+++ b/screenpipe-app-tauri/src-tauri/src/main.rs
@@ -867,11 +867,6 @@ async fn main() {
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");
diff --git a/screenpipe-app-tauri/src-tauri/src/sidecar.rs b/screenpipe-app-tauri/src-tauri/src/sidecar.rs
index c4b1da461..63eae390a 100644
--- a/screenpipe-app-tauri/src-tauri/src/sidecar.rs
+++ b/screenpipe-app-tauri/src-tauri/src/sidecar.rs
@@ -521,7 +521,7 @@ impl SidecarManager {
let child = spawn_sidecar(app)?;
self.child = Some(child);
self.last_restart = Instant::now();
- debug!("last_restart: {:?}", self.last_restart);
+ info!("last restart: {:?}", self.last_restart);
// kill previous task if any
if let Some(task) = self.restart_task.take() {
@@ -529,6 +529,7 @@ impl SidecarManager {
}
let restart_interval = self.restart_interval.clone();
+ info!("restart_interval: {:?}", restart_interval);
// Add this function outside the SidecarManager impl
async fn check_and_restart_sidecar(app_handle: &tauri::AppHandle) -> Result<(), String> {
let state = app_handle.state::<SidecarState>();
@@ -545,7 +546,7 @@ impl SidecarManager {
self.restart_task = Some(tauri::async_runtime::spawn(async move {
loop {
let interval = *restart_interval.lock().await;
- debug!("interval: {}", interval.as_secs());
+ info!("interval: {}", interval.as_secs());
if let Err(e) = check_and_restart_sidecar(&app_handle).await {
error!("Failed to check and restart sidecar: {}", e);
}
@@ -582,20 +583,42 @@ impl SidecarManager {
pub async fn check_and_restart(&mut self, app: &tauri::AppHandle) -> Result<(), String> {
let interval = *self.restart_interval.lock().await;
let dev_mode = *self.dev_mode.lock().await;
- debug!("interval: {}", interval.as_secs());
- debug!("last_restart: {:?}", self.last_restart);
- debug!("elapsed: {:?}", self.last_restart.elapsed());
+ info!("interval: {}", interval.as_secs());
+ info!("last_restart: {:?}", self.last_restart);
+ info!("elapsed: {:?}", self.last_restart.elapsed());
+
if interval.as_secs() > 0 && self.last_restart.elapsed() >= interval && !dev_mode {
- debug!("Restarting sidecar due to restart interval");
+ info!("attempting to restart sidecar due to restart interval");
+
+ // Safely kill the existing sidecar
if let Some(child) = self.child.take() {
- let _ = child.kill();
+ match child.kill() {
+ Ok(_) => info!("successfully killed previous sidecar"),
+ Err(e) => {
+ error!("failed to kill previous sidecar: {}", e);
+ // Continue anyway as the process might have already died
+ }
+ }
}
- // sleep for 5 seconds
+
+ // Wait for process cleanup
sleep(Duration::from_secs(5)).await;
- let child = spawn_sidecar(app)?;
- self.child = Some(child);
- self.last_restart = Instant::now();
+
+ // Try to spawn new sidecar
+ match spawn_sidecar(app) {
+ Ok(new_child) => {
+ info!("successfully spawned new sidecar");
+ self.child = Some(new_child);
+ self.last_restart = Instant::now();
+ }
+ Err(e) => {
+ error!("failed to spawn new sidecar: {}", e);
+ // Don't propagate error - let the app continue running
+ // The next check interval will try again
+ }
+ }
}
+
Ok(())
}
}
diff --git a/screenpipe-app-tauri/src-tauri/src/updates.rs b/screenpipe-app-tauri/src-tauri/src/updates.rs
index cfda7b470..654ee24bc 100644
--- a/screenpipe-app-tauri/src-tauri/src/updates.rs
+++ b/screenpipe-app-tauri/src-tauri/src/updates.rs
@@ -45,7 +45,7 @@ impl UpdatesManager {
}
}
if cfg!(debug_assertions) {
- println!("dev mode is enabled, skipping update check");
+ info!("dev mode is enabled, skipping update check");
return Result::Ok(false);
}
diff --git a/screenpipe-server/src/server.rs b/screenpipe-server/src/server.rs
index 92a9cb6ea..67ad1e7c2 100644
--- a/screenpipe-server/src/server.rs
+++ b/screenpipe-server/src/server.rs
@@ -69,9 +69,7 @@ use screenpipe_audio::LAST_AUDIO_CAPTURE;
use std::str::FromStr;
use crate::text_embeds::generate_embedding;
-use std::collections::HashMap;
-use dirs::data_local_dir as local_data_dir;
-use tokio::fs;
+
pub struct AppState {
pub db: Arc<DatabaseManager>,