fix: enable systemd lingering for gateway

This commit is contained in:
Peter Steinberger
2026-01-05 18:38:30 +01:00
parent 0fb30db819
commit ad6bec4612
12 changed files with 346 additions and 25 deletions

View File

@@ -31,6 +31,7 @@ import type { RuntimeEnv } from "../runtime.js";
import { defaultRuntime } from "../runtime.js";
import { resolveUserPath, sleep } from "../utils.js";
import { healthCommand } from "./health.js";
import { ensureSystemdUserLingerInteractive } from "./systemd-linger.js";
import {
applyWizardMetadata,
DEFAULT_WORKSPACE,
@@ -599,6 +600,28 @@ export async function doctorCommand(runtime: RuntimeEnv = defaultRuntime) {
await maybeMigrateLegacyGatewayService(cfg, runtime);
if (process.platform === "linux" && resolveMode(cfg) === "local") {
const service = resolveGatewayService();
let loaded = false;
try {
loaded = await service.isLoaded({ env: process.env });
} catch {
loaded = false;
}
if (loaded) {
await ensureSystemdUserLingerInteractive({
runtime,
prompter: {
confirm: (params) => guardCancel(confirm(params), runtime),
note,
},
reason:
"Gateway runs as a systemd user service. Without lingering, systemd stops the user session on logout/idle and kills the Gateway.",
requireConfirm: true,
});
}
}
const workspaceDir = resolveUserPath(
cfg.agent?.workspace ?? DEFAULT_WORKSPACE,
);