From 57fa18b94060cadca80e0687eed674bd0042da8c Mon Sep 17 00:00:00 2001 From: Akos Kitta Date: Sun, 20 Aug 2023 18:09:48 +0200 Subject: [PATCH] fix: do not start obsolete daemon watcher process Before arduino/arduino-cli#488, IDE2 required a way to stop the daemon process if the parent (backend) process crashed. However, this mechanism is no longer necessary as the CLI daemon process is not actually a true daemon process. Signed-off-by: Akos Kitta --- .../src/node/arduino-daemon-impl.ts | 17 -------------- .../src/node/daemon-watcher.ts | 22 ------------------- 2 files changed, 39 deletions(-) delete mode 100644 arduino-ide-extension/src/node/daemon-watcher.ts diff --git a/arduino-ide-extension/src/node/arduino-daemon-impl.ts b/arduino-ide-extension/src/node/arduino-daemon-impl.ts index b7af78627..16db90631 100644 --- a/arduino-ide-extension/src/node/arduino-daemon-impl.ts +++ b/arduino-ide-extension/src/node/arduino-daemon-impl.ts @@ -10,7 +10,6 @@ import { } from '@theia/core/lib/common/disposable'; import { Event, Emitter } from '@theia/core/lib/common/event'; import { deepClone } from '@theia/core/lib/common/objects'; -import { environment } from '@theia/application-package/lib/environment'; import { EnvVariablesServer } from '@theia/core/lib/common/env-variables'; import { BackendApplicationContribution } from '@theia/core/lib/node/backend-application'; import { ArduinoDaemon, NotificationServiceServer } from '../common/protocol'; @@ -71,22 +70,6 @@ export class ArduinoDaemonImpl const cliPath = this.getExecPath(); this.onData(`Starting daemon from ${cliPath}...`); const { daemon, port } = await this.spawnDaemonProcess(); - // Watchdog process for terminating the daemon process when the backend app terminates. - spawn( - process.execPath, - [ - join(__dirname, 'daemon-watcher.js'), - String(process.pid), - String(daemon.pid), - ], - { - env: environment.electron.runAsNodeEnv(), - detached: true, - stdio: 'ignore', - windowsHide: true, - } - ).unref(); - this.toDispose.pushAll([ Disposable.create(() => { if (daemon.pid) { diff --git a/arduino-ide-extension/src/node/daemon-watcher.ts b/arduino-ide-extension/src/node/daemon-watcher.ts deleted file mode 100644 index 842a4e2f2..000000000 --- a/arduino-ide-extension/src/node/daemon-watcher.ts +++ /dev/null @@ -1,22 +0,0 @@ -import psTree from 'ps-tree'; -import kill from 'tree-kill'; -const [theiaPid, daemonPid] = process.argv - .slice(2) - .map((id) => Number.parseInt(id, 10)); - -setInterval(() => { - try { - // Throws an exception if the Theia process doesn't exist anymore. - process.kill(theiaPid, 0); - } catch { - psTree(daemonPid, function (_, children) { - for (const { PID } of children) { - const parsedPid = Number.parseInt(PID, 10); - if (!Number.isNaN(parsedPid)) { - kill(parsedPid); - } - } - kill(daemonPid, () => process.exit()); - }); - } -}, 1000);