fix(gateway): trace restart intent reasons

This commit is contained in:
Peter Steinberger
2026-05-16 21:20:59 +01:00
parent c421be6c90
commit 6369bf64cd
8 changed files with 72 additions and 6 deletions

View File

@@ -346,7 +346,10 @@ describe("runServiceRestart token drift", () => {
await runServiceRestart(createServiceRunArgs());
expect(writeGatewayRestartIntentSync).toHaveBeenCalledWith({ targetPid: 1234 });
expect(writeGatewayRestartIntentSync).toHaveBeenCalledWith({
targetPid: 1234,
reason: "gateway.restart",
});
expect(clearGatewayRestartIntentSync).not.toHaveBeenCalled();
expect(service.restart).toHaveBeenCalledTimes(1);
});
@@ -366,6 +369,7 @@ describe("runServiceRestart token drift", () => {
expect(writeGatewayRestartIntentSync).toHaveBeenCalledWith({
targetPid: 1234,
reason: "gateway.restart",
intent: {
waitMs: 2_500,
},
@@ -379,7 +383,10 @@ describe("runServiceRestart token drift", () => {
await expect(runServiceRestart(createServiceRunArgs())).rejects.toThrow("__exit__:1");
expect(writeGatewayRestartIntentSync).toHaveBeenCalledWith({ targetPid: 1234 });
expect(writeGatewayRestartIntentSync).toHaveBeenCalledWith({
targetPid: 1234,
reason: "gateway.restart",
});
expect(clearGatewayRestartIntentSync).toHaveBeenCalledOnce();
});

View File

@@ -574,6 +574,7 @@ export async function runServiceRestart(params: {
const runtime = await params.service.readRuntime(process.env).catch(() => null);
wroteRestartIntent = writeGatewayRestartIntentSync({
targetPid: runtime?.pid,
reason: "gateway.restart",
...(restartIntent ? { intent: restartIntent } : {}),
});
}

View File

@@ -208,6 +208,7 @@ async function restartGatewayWithoutServiceManager(
}
writeGatewayRestartIntentSync({
targetPid: pids[0],
reason: "gateway.restart",
...(restartIntent ? { intent: restartIntent } : {}),
});
signalVerifiedGatewayPidSync(pids[0], "SIGUSR1");