Skip to content

Commit be39b0e

Browse files
committed
feat: send SIGTERM to gptme-server on app exit
1 parent e5f86d3 commit be39b0e

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src-tauri/src/lib.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use tauri_plugin_dialog::{
55
DialogExt, MessageDialogBuilder, MessageDialogButtons, MessageDialogKind,
66
};
77
use tauri_plugin_log::{Target, TargetKind};
8-
use tauri_plugin_shell::{process::CommandChild, ShellExt};
8+
use tauri_plugin_shell::ShellExt;
99

1010
const GPTME_SERVER_PORT: u16 = 5700;
1111

@@ -43,9 +43,9 @@ pub fn run() {
4343

4444
let app_handle = app.handle().clone();
4545

46-
// Store child process reference for cleanup
47-
let child_process: Arc<Mutex<Option<CommandChild>>> = Arc::new(Mutex::new(None));
48-
let child_for_cleanup = child_process.clone();
46+
// Store child process PID for cleanup
47+
let child_pid: Arc<Mutex<Option<u32>>> = Arc::new(Mutex::new(None));
48+
let child_pid_for_cleanup = child_pid.clone();
4949

5050
// Spawn gptme-server with output capture
5151
tauri::async_runtime::spawn(async move {
@@ -101,9 +101,9 @@ pub fn run() {
101101
child.pid()
102102
);
103103

104-
// Store child process reference
105-
if let Ok(mut child_ref) = child_process.lock() {
106-
*child_ref = Some(child);
104+
// Store child process PID
105+
if let Ok(mut pid_ref) = child_pid.lock() {
106+
*pid_ref = Some(child.pid());
107107
}
108108

109109
// Handle server output
@@ -149,8 +149,8 @@ pub fn run() {
149149
}
150150
});
151151

152-
// Store child process reference in app state for cleanup
153-
app.manage(child_for_cleanup);
152+
// Store child process PID in app state for cleanup
153+
app.manage(child_pid_for_cleanup);
154154

155155
Ok(())
156156
})

0 commit comments

Comments
 (0)