fix: verify gateway restart health after daemon restart

This commit is contained in:
Peter Steinberger
2026-02-21 18:02:05 +01:00
parent 5e34eb98fb
commit 905e355f65
5 changed files with 408 additions and 141 deletions

View File

@@ -1,3 +1,4 @@
import type { Writable } from "node:stream";
import { loadConfig } from "../../config/config.js";
import { resolveIsNixMode } from "../../config/paths.js";
import { checkTokenDrift } from "../../daemon/service-audit.js";
@@ -18,6 +19,13 @@ type DaemonLifecycleOptions = {
json?: boolean;
};
type RestartPostCheckContext = {
json: boolean;
stdout: Writable;
warnings: string[];
fail: (message: string, hints?: string[]) => void;
};
async function maybeAugmentSystemdHints(hints: string[]): Promise<string[]> {
if (process.platform !== "linux") {
return hints;
@@ -240,6 +248,7 @@ export async function runServiceRestart(params: {
renderStartHints: () => string[];
opts?: DaemonLifecycleOptions;
checkTokenDrift?: boolean;
postRestartCheck?: (ctx: RestartPostCheckContext) => Promise<void>;
}): Promise<boolean> {
const json = Boolean(params.opts?.json);
const { stdout, emit, fail } = createActionIO({ action: "restart", json });
@@ -295,6 +304,9 @@ export async function runServiceRestart(params: {
try {
await params.service.restart({ env: process.env, stdout });
if (params.postRestartCheck) {
await params.postRestartCheck({ json, stdout, warnings, fail });
}
let restarted = true;
try {
restarted = await params.service.isLoaded({ env: process.env });