mirror of
https://github.com/Corfirean/coa-server-manager.git
synced 2026-11-22 03:25:56 +00:00
Stabilize server lifecycle, client settings and release qualification
This commit is contained in:
1 parent
4d1a6e0b21
commit
30d2f56997
71 files changed
+2785
-168
No files matched your search
@@ -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;
|
||||
}
|
||||
Reference in new issue
Block a user