feat(update): add core auto-updater and dry-run preview

This commit is contained in:
Peter Steinberger
2026-02-22 17:11:24 +01:00
parent 13690d406a
commit f442a3539f
15 changed files with 673 additions and 45 deletions

View File

@@ -15,6 +15,7 @@ export function createGatewayCloseHandler(params: {
pluginServices: PluginServicesHandle | null;
cron: { stop: () => void };
heartbeatRunner: HeartbeatRunner;
updateCheckStop?: (() => void) | null;
nodePresenceTimers: Map<string, ReturnType<typeof setInterval>>;
broadcast: (event: string, payload: unknown, opts?: { dropIfSlow?: boolean }) => void;
tickInterval: ReturnType<typeof setInterval>;
@@ -70,6 +71,11 @@ export function createGatewayCloseHandler(params: {
await stopGmailWatcher();
params.cron.stop();
params.heartbeatRunner.stop();
try {
params.updateCheckStop?.();
} catch {
/* ignore */
}
for (const timer of params.nodePresenceTimers.values()) {
clearInterval(timer);
}

View File

@@ -632,17 +632,17 @@ export async function startGatewayServer(
log,
isNixMode,
});
if (!minimalTestGateway) {
scheduleGatewayUpdateCheck({
cfg: cfgAtStart,
log,
isNixMode,
onUpdateAvailableChange: (updateAvailable) => {
const payload: GatewayUpdateAvailableEventPayload = { updateAvailable };
broadcast(GATEWAY_EVENT_UPDATE_AVAILABLE, payload, { dropIfSlow: true });
},
});
}
const stopGatewayUpdateCheck = minimalTestGateway
? () => {}
: scheduleGatewayUpdateCheck({
cfg: cfgAtStart,
log,
isNixMode,
onUpdateAvailableChange: (updateAvailable) => {
const payload: GatewayUpdateAvailableEventPayload = { updateAvailable };
broadcast(GATEWAY_EVENT_UPDATE_AVAILABLE, payload, { dropIfSlow: true });
},
});
const tailscaleCleanup = minimalTestGateway
? null
: await startGatewayTailscaleExposure({
@@ -730,6 +730,7 @@ export async function startGatewayServer(
pluginServices,
cron,
heartbeatRunner,
updateCheckStop: stopGatewayUpdateCheck,
nodePresenceTimers,
broadcast,
tickInterval,