Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix process killing #1230

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions screenpipe-app-tauri/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export default function Home() {
}),

listen("shortcut-stop-recording", async () => {
await invoke("kill_all_sreenpipes");
await invoke("kill_all_screenpipes");

toast({
title: "recording stopped",
Expand All @@ -90,7 +90,7 @@ export default function Home() {
description: `switched to ${profile} profile, restarting screenpipe now`,
});

await invoke("kill_all_sreenpipes");
await invoke("kill_all_screenpipes");

await new Promise((resolve) => setTimeout(resolve, 1000));

Expand Down
2 changes: 1 addition & 1 deletion screenpipe-app-tauri/components/dev-mode-settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export const DevModeSettings = ({ localDataDir }: { localDataDir: string }) => {
duration: Infinity,
});
try {
await invoke("kill_all_sreenpipes");
await invoke("kill_all_screenpipes");
await new Promise((resolve) => setTimeout(resolve, 2000));
toastId.update({
id: toastId.id,
Expand Down
2 changes: 1 addition & 1 deletion screenpipe-app-tauri/components/onboarding/pipe-store.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const OnboardingPipeStore: React.FC<OnboardingPipeStoreProps> = ({
await fetch("http://localhost:3030/health");
} catch (error) {
// Screenpipe not running, try to spawn it
await invoke("kill_all_sreenpipes");
await invoke("kill_all_screenpipes");
await new Promise((resolve) => setTimeout(resolve, 1_000));
await invoke("spawn_screenpipe");
await new Promise((resolve) => setTimeout(resolve, 5_000));
Expand Down
2 changes: 1 addition & 1 deletion screenpipe-app-tauri/components/onboarding/status.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ const OnboardingStatus: React.FC<OnboardingStatusProps> = ({
duration: Infinity,
});
try {
await invoke("kill_all_sreenpipes");
await invoke("kill_all_screenpipes");
await new Promise((resolve) => setTimeout(resolve, 1_000));

await invoke("spawn_screenpipe");
Expand Down
2 changes: 1 addition & 1 deletion screenpipe-app-tauri/components/recording-settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ export function RecordingSettings() {
}
}

await invoke("kill_all_sreenpipes");
await invoke("kill_all_screenpipes");

await new Promise((resolve) => setTimeout(resolve, 1000));
// Start a new instance with updated settings
Expand Down
2 changes: 1 addition & 1 deletion screenpipe-app-tauri/components/settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export function Settings() {
title: "Restarting Screenpipe",
description: "Please wait while we restart Screenpipe",
});
await invoke("kill_all_sreenpipes");
await invoke("kill_all_screenpipes");

await new Promise((resolve) => setTimeout(resolve, 1000));

Expand Down
2 changes: 1 addition & 1 deletion screenpipe-app-tauri/components/updater.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Release notes: ${update.body}
// on windows only - TODO shouldnt be necessary
const os = platform();
if (os === "windows") {
await invoke("kill_all_sreenpipes");
await invoke("kill_all_screenpipes");
}

const toastId = toast({
Expand Down
10 changes: 5 additions & 5 deletions screenpipe-app-tauri/src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pub use commands::reset_all_pipes;
pub use commands::set_tray_health_icon;
pub use commands::set_tray_unhealth_icon;
pub use server::spawn_server;
pub use sidecar::kill_all_sreenpipes;
pub use sidecar::kill_all_screenpipes;
pub use sidecar::spawn_screenpipe;
pub use store::get_profiles_store;
pub use store::get_store;
Expand Down Expand Up @@ -660,7 +660,7 @@ async fn main() {
.manage(sidecar_state)
.invoke_handler(tauri::generate_handler![
spawn_screenpipe,
kill_all_sreenpipes,
kill_all_screenpipes,
permissions::open_permission_settings,
permissions::request_permission,
permissions::do_permissions_check,
Expand Down Expand Up @@ -811,7 +811,7 @@ async fn main() {
// Stop any running recordings
let state = app_handle_clone.state::<SidecarState>();
if let Err(e) =
kill_all_sreenpipes(state, app_handle_clone.clone()).await
kill_all_screenpipes(state, app_handle_clone.clone()).await
{
error!("Error stopping recordings during quit: {}", e);
}
Expand Down Expand Up @@ -839,7 +839,7 @@ async fn main() {
let app_handle = app_handle.clone();
tauri::async_runtime::spawn(async move {
let state = app_handle.state::<SidecarState>();
if let Err(err) = kill_all_sreenpipes(state, app_handle.clone()).await {
if let Err(err) = kill_all_screenpipes(state, app_handle.clone()).await {
error!("Failed to stop recording: {}", err);
let _ = app_handle
.notification()
Expand Down Expand Up @@ -872,7 +872,7 @@ async fn main() {

tokio::task::block_in_place(move || {
Handle::current().block_on(async move {
if let Err(err) = sidecar::kill_all_sreenpipes(
if let Err(err) = sidecar::kill_all_screenpipes(
app_handle.state::<SidecarState>(),
app_handle.clone(),
)
Expand Down
2 changes: 1 addition & 1 deletion screenpipe-app-tauri/src-tauri/src/sidecar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ impl User {
}

#[tauri::command]
pub async fn kill_all_sreenpipes(
pub async fn kill_all_screenpipes(
state: State<'_, SidecarState>,
_app: tauri::AppHandle,
) -> Result<(), String> {
Expand Down
6 changes: 3 additions & 3 deletions screenpipe-app-tauri/src-tauri/src/updates.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::kill_all_sreenpipes;
use crate::kill_all_screenpipes;
use crate::SidecarState;
use anyhow::Error;
use log::{error, info};
Expand Down Expand Up @@ -107,7 +107,7 @@ impl UpdatesManager {
.set_text("downloading latest version of screenpipe")?;

if let Err(err) =
kill_all_sreenpipes(self.app.state::<SidecarState>(), self.app.clone())
kill_all_screenpipes(self.app.state::<SidecarState>(), self.app.clone())
.await
{
error!("Failed to kill sidecar: {}", err);
Expand All @@ -131,7 +131,7 @@ impl UpdatesManager {
#[cfg(not(target_os = "windows"))]
{
if let Err(err) =
kill_all_sreenpipes(self.app.state::<SidecarState>(), self.app.clone())
kill_all_screenpipes(self.app.state::<SidecarState>(), self.app.clone())
.await
{
error!("Failed to kill sidecar: {}", err);
Expand Down
6 changes: 5 additions & 1 deletion screenpipe-server/src/pipe_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -350,8 +350,10 @@
}
#[cfg(windows)]
{
use windows::Win32::Foundation::CloseHandle;
use windows::Win32::System::Threading::{
OpenProcess, TerminateProcess, PROCESS_ACCESS_RIGHTS,
INFINITE, WaitForSingleObject
};
unsafe {
if let Ok(h_process) = OpenProcess(
Expand All @@ -360,7 +362,9 @@
pid as u32,
) {
let _ = TerminateProcess(h_process, 1);
}
WaitForSingleObject(h_process, INFINITE);
CloseHandle(h_process);

Check warning on line 366 in screenpipe-server/src/pipe_manager.rs

View workflow job for this annotation

GitHub Actions / test-windows

unused `Result` that must be used

Check warning on line 366 in screenpipe-server/src/pipe_manager.rs

View workflow job for this annotation

GitHub Actions / test-windows

unused `Result` that must be used
}
}
}
}
Expand Down
Loading