From 34dcdd5d8a88d4226a0315a29017320ef173e05e Mon Sep 17 00:00:00 2001 From: DJ2LS Date: Sat, 2 Mar 2024 11:38:09 +0100 Subject: [PATCH] fixed copy and paste error --- gui/electron/main/index.ts | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/gui/electron/main/index.ts b/gui/electron/main/index.ts index 9a9cf2f2..c3eef6cc 100644 --- a/gui/electron/main/index.ts +++ b/gui/electron/main/index.ts @@ -73,9 +73,9 @@ async function createWindow() { } // Test actively push message to the Electron-Renderer - win.webContents.on("did-finish-load", () => { - win?.webContents.send("main-process-message", new Date().toLocaleString()); - }); + //win.webContents.on("did-finish-load", () => { + // win?.webContents.send("main-process-message", new Date().toLocaleString()); + //}); // Make all links open with the browser, not with the application win.webContents.setWindowOpenHandler(({ url }) => { @@ -196,13 +196,26 @@ function close_sub_processes() { if (serverProcess != null) { try { console.log(`Killing server process with PID: ${serverProcess.pid}`); - // For Windows, use taskkill to ensure all child processes are also terminated - if (isWindows) { - spawn("taskkill", ["/pid", serverProcess.pid.toString(), "/f", "/t"]); - } else { - // On macOS and Linux, sending SIGTERM should suffice - process.kill(serverProcess.pid); - } + + switch (platform().toLowerCase()) { + //case "darwin": + // process.kill(serverProcess.pid); + // break; + //case "linux": + // process.kill(serverProcess.pid); + // break; + case "win32": + // For Windows, use taskkill to ensure all child processes are also terminated + spawn("taskkill", ["/pid", serverProcess.pid.toString(), "/f", "/t"]); + break; + + default: + console.log("Unhandled OS Platform: ", platform()); + serverProcess = null; + serverPath = null; + break; + } + } catch (error) { console.error(`Error killing server process: ${error}`); }