fix: preserve aggregate HWPOD lifecycle actions

This commit is contained in:
root
2026-07-23 06:46:50 +02:00
parent 3311348f34
commit a79c9c6a43
2 changed files with 5 additions and 4 deletions
+1
View File
@@ -31,6 +31,7 @@ test("aggregate stop owns all HWPOD native services", async () => {
expect(result.ok).toBe(true);
expect(Object.keys(result.services).sort()).toEqual(["api", "web", "worker"]);
expect(result.summary.completed).toBe(3);
expect(Object.values(result.services).every((service) => service.operation.endsWith(".stop"))).toBe(true);
} finally {
await rm(cwd, { recursive: true, force: true });
}
+4 -4
View File
@@ -27,21 +27,21 @@ export async function hwpodNativeServicesStatus(input: { cwd: string; env: Recor
export async function hwpodNativeServicesCommand(input: { action: string; cwd: string; env: Record<string, string | undefined> }) {
if (input.action === "status") return hwpodNativeServicesStatus(input);
if (input.action === "logs") {
const results = await Promise.all(SERVICE_NAMES.map((service) => hwpodNativeServiceCommand({ service, action: "logs", ...input })));
const results = await Promise.all(SERVICE_NAMES.map((service) => hwpodNativeServiceCommand({ ...input, service, action: "logs" })));
return aggregateResult("logs", results);
}
if (input.action === "stop") {
const results = [];
for (const service of [...SERVICE_NAMES].reverse()) results.push(await hwpodNativeServiceCommand({ service, action: "stop", ...input }));
for (const service of [...SERVICE_NAMES].reverse()) results.push(await hwpodNativeServiceCommand({ ...input, service, action: "stop" }));
return aggregateResult("stop", results);
}
if (input.action === "start" || input.action === "restart") {
const stopped = [];
if (input.action === "restart") {
for (const service of [...SERVICE_NAMES].reverse()) stopped.push(await hwpodNativeServiceCommand({ service, action: "stop", ...input }));
for (const service of [...SERVICE_NAMES].reverse()) stopped.push(await hwpodNativeServiceCommand({ ...input, service, action: "stop" }));
}
const started = [];
for (const service of SERVICE_NAMES) started.push(await hwpodNativeServiceCommand({ service, action: "start", ...input }));
for (const service of SERVICE_NAMES) started.push(await hwpodNativeServiceCommand({ ...input, service, action: "start" }));
const readiness = await waitForServicesReady(input);
return { ...aggregateResult(input.action, started), stopped, readiness, ok: readiness.ok, status: readiness.status };
}