From b0718db6e5a22198449f976468ec4889754fb0df Mon Sep 17 00:00:00 2001 From: Eser DENIZ Date: Tue, 21 Jan 2025 14:15:02 +0100 Subject: [PATCH] fix: kill tree php server (#157) --- resources/js/electron-plugin/dist/index.js | 2 ++ resources/js/electron-plugin/src/index.ts | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/resources/js/electron-plugin/dist/index.js b/resources/js/electron-plugin/dist/index.js index b478541..568eb7d 100644 --- a/resources/js/electron-plugin/dist/index.js +++ b/resources/js/electron-plugin/dist/index.js @@ -16,6 +16,7 @@ import { notifyLaravel } from "./server/utils.js"; import { resolve } from "path"; import { stopAllProcesses } from "./server/api/childProcess.js"; import ps from "ps-node"; +import killSync from "kill-sync"; import electronUpdater from 'electron-updater'; const { autoUpdater } = electronUpdater; class NativePHP { @@ -173,6 +174,7 @@ class NativePHP { .filter((p) => p !== undefined) .forEach((process) => { try { + killSync(process.pid, 'SIGTERM', true); ps.kill(process.pid); } catch (err) { diff --git a/resources/js/electron-plugin/src/index.ts b/resources/js/electron-plugin/src/index.ts index 616c4f8..d825299 100644 --- a/resources/js/electron-plugin/src/index.ts +++ b/resources/js/electron-plugin/src/index.ts @@ -14,6 +14,7 @@ import { notifyLaravel } from "./server/utils.js"; import { resolve } from "path"; import { stopAllProcesses } from "./server/api/childProcess.js"; import ps from "ps-node"; +import killSync from "kill-sync"; // Workaround for CommonJS module import electronUpdater from 'electron-updater'; @@ -241,7 +242,9 @@ class NativePHP { .filter((p) => p !== undefined) .forEach((process) => { try { - ps.kill(process.pid); + // @ts-ignore + killSync(process.pid, 'SIGTERM', true); // Kill tree + ps.kill(process.pid); // Sometimes does not kill the subprocess of php server } catch (err) { console.error(err); }