From b1b7d13dbf5b9f6ada28a5ef22ea6857d3b0bcb6 Mon Sep 17 00:00:00 2001 From: Nate Sesti <sestinj@gmail.com> Date: Fri, 25 Aug 2023 18:22:16 -0700 Subject: fix: :bug: force kill old server with taskkill on windows --- extension/src/activation/environmentSetup.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'extension/src/activation') diff --git a/extension/src/activation/environmentSetup.ts b/extension/src/activation/environmentSetup.ts index 23c0d7de..2067f0fb 100644 --- a/extension/src/activation/environmentSetup.ts +++ b/extension/src/activation/environmentSetup.ts @@ -101,6 +101,25 @@ async function checkOrKillRunningServer(serverUrl: string): Promise<boolean> { } catch (e: any) { if (!e.message.includes("Process doesn't exist")) { console.log("Failed to kill old server:", e); + + // Try again, on Windows. This time with taskkill + if (os.platform() === "win32") { + try { + const exePath = path.join( + getExtensionUri().fsPath, + "server", + "exe", + "run.exe" + ); + + await runCommand(`taskkill /F /IM ${exePath}`); + } catch (e: any) { + console.log( + "Failed to kill old server second time on windows with taskkill:", + e + ); + } + } } } if (fs.existsSync(serverVersionPath())) { -- cgit v1.2.3-70-g09d2