Clean up Windows smoke relay shutdown
This commit is contained in:
@@ -443,6 +443,7 @@ jobs:
|
|||||||
exit 1
|
exit 1
|
||||||
|
|
||||||
- name: Smoke check managed runtime for Windows
|
- name: Smoke check managed runtime for Windows
|
||||||
|
timeout-minutes: 12
|
||||||
env:
|
env:
|
||||||
PASEO_MANAGED_SMOKE_SKIP_BUILD: "1"
|
PASEO_MANAGED_SMOKE_SKIP_BUILD: "1"
|
||||||
run: npm run smoke:managed-daemon --workspace=@getpaseo/desktop
|
run: npm run smoke:managed-daemon --workspace=@getpaseo/desktop
|
||||||
|
|||||||
@@ -110,6 +110,19 @@ function escapeForRegExp(value) {
|
|||||||
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function waitForChildExit(child, timeoutMs) {
|
||||||
|
if (!child || child.exitCode !== null || child.killed) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await new Promise((resolve) => {
|
||||||
|
const timeout = setTimeout(resolve, timeoutMs);
|
||||||
|
child.once("exit", () => {
|
||||||
|
clearTimeout(timeout);
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
async function execFileWithTimeout(command, args, options, label) {
|
async function execFileWithTimeout(command, args, options, label) {
|
||||||
try {
|
try {
|
||||||
return await execFileAsync(command, args, {
|
return await execFileAsync(command, args, {
|
||||||
@@ -141,6 +154,34 @@ async function runBinary(binaryPath, args, env) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function terminateChildProcess(child, label) {
|
||||||
|
if (!child || child.exitCode !== null || child.killed) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (process.platform === "win32" && typeof child.pid === "number") {
|
||||||
|
try {
|
||||||
|
await execFileWithTimeout(
|
||||||
|
"taskkill",
|
||||||
|
["/pid", String(child.pid), "/T", "/F"],
|
||||||
|
{ maxBuffer: 1024 * 1024 },
|
||||||
|
`${label} taskkill`
|
||||||
|
);
|
||||||
|
} catch {}
|
||||||
|
await waitForChildExit(child, 5_000);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
child.kill("SIGTERM");
|
||||||
|
} catch {}
|
||||||
|
await waitForChildExit(child, 5_000);
|
||||||
|
if (child.exitCode === null && !child.killed) {
|
||||||
|
try {
|
||||||
|
child.kill("SIGKILL");
|
||||||
|
} catch {}
|
||||||
|
await waitForChildExit(child, 5_000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function runWorkspaceCli(args, env) {
|
async function runWorkspaceCli(args, env) {
|
||||||
const { stdout, stderr } = await execFileWithTimeout(
|
const { stdout, stderr } = await execFileWithTimeout(
|
||||||
process.execPath,
|
process.execPath,
|
||||||
@@ -808,6 +849,6 @@ try {
|
|||||||
}
|
}
|
||||||
} catch {}
|
} catch {}
|
||||||
try {
|
try {
|
||||||
relayProcess?.kill("SIGTERM");
|
await terminateChildProcess(relayProcess, "local relay");
|
||||||
} catch {}
|
} catch {}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user