fix: add gateway stop/restart commands

This commit is contained in:
Peter Steinberger
2026-01-06 03:25:21 +01:00
parent cc0ef4d012
commit 0398f684e7
18 changed files with 339 additions and 28 deletions

View File

@@ -233,6 +233,28 @@ export async function uninstallScheduledTask({
}
}
function isTaskNotRunning(res: {
stdout: string;
stderr: string;
code: number;
}): boolean {
const detail = `${res.stderr || res.stdout}`.toLowerCase();
return detail.includes("not running");
}
export async function stopScheduledTask({
stdout,
}: {
stdout: NodeJS.WritableStream;
}): Promise<void> {
await assertSchtasksAvailable();
const res = await execSchtasks(["/End", "/TN", GATEWAY_WINDOWS_TASK_NAME]);
if (res.code !== 0 && !isTaskNotRunning(res)) {
throw new Error(`schtasks end failed: ${res.stderr || res.stdout}`.trim());
}
stdout.write(`Stopped Scheduled Task: ${GATEWAY_WINDOWS_TASK_NAME}\n`);
}
export async function restartScheduledTask({
stdout,
}: {