export async function ensureSystemdUserLingerInteractive(params: {
runtime: RuntimeEnv;
prompter?: LingerPrompter;
env?: NodeJS.ProcessEnv;
title?: string;
reason?: string;
prompt?: boolean;
requireConfirm?: boolean;
}): Promise<void> { if (process.platform !== "linux") { return;
} if (params.prompt === false) { return;
} const env = params.env ?? process.env; const prompter = params.prompter ?? { note }; const title = params.title ?? "Systemd"; if (!(await isSystemdUserServiceAvailable())) {
await prompter.note("Systemd user services are unavailable. Skipping lingering checks.", title); return;
} const status = await readSystemdUserLingerStatus(env); if (!status) {
await prompter.note( "Unable to read loginctl linger status. Ensure systemd + loginctl are available.",
title,
); return;
} if (status.linger === "yes") { return;
}
const reason =
params.reason ?? "Systemd user services stop when you log out or go idle, which kills the Gateway."; const actionNote = params.requireConfirm
? "We can enable lingering now (may require sudo; writes /var/lib/systemd/linger)."
: "Enabling lingering now (may require sudo; writes /var/lib/systemd/linger).";
await prompter.note(`${reason}\n${actionNote}`, title);
if (params.requireConfirm && prompter.confirm) { const ok = await prompter.confirm({
message: `Enable systemd lingering for ${status.user}?`,
initialValue: true,
}); if (!ok) {
await prompter.note("Without lingering, the Gateway will stop when you log out.", title); return;
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.