Stabilize server lifecycle, client settings and release qualification

This commit is contained in:
Дмитрий committed 2026-10-30 14:04:18 +05:00
1 parent 4d1a6e0b21
commit 30d2f56997
71 files changed
+2785 -168

No files matched your search

+38
View File
@@ -0,0 +1,38 @@
export class ServerLifecycle {
private wasRunning = false;
private maintenance = false;
private stopRequested = false;
private operationPending = false;
request(action: "starting" | "stopping" | "restarting") {
this.stopRequested = action !== "starting";
this.operationPending = true;
}
complete(action: "starting" | "stopping" | "restarting") {
this.operationPending = false;
if (action !== "stopping") { this.stopRequested = false; this.wasRunning = false; }
}
beginMaintenance() { this.maintenance = true; this.wasRunning = false; }
endMaintenance() { this.maintenance = false; this.wasRunning = false; }
observe(running: boolean, busy: boolean, updating: boolean): boolean {
if (this.maintenance) { this.wasRunning = false; return false; }
if (running) { this.wasRunning = true; return false; }
if (this.stopRequested || updating || this.operationPending) {
this.wasRunning = false;
if (!busy && !this.operationPending) this.stopRequested = false;
return false;
}
if (this.wasRunning && !busy) { this.wasRunning = false; return true; }
return false;
}
}
const lifecycles = new Map<string, ServerLifecycle>();
export function serverLifecycle(id: string) {
let lifecycle = lifecycles.get(id);
if (!lifecycle) { lifecycle = new ServerLifecycle(); lifecycles.set(id, lifecycle); }
return lifecycle;
}