Admin: Auslastung der Docker-Hosts mit den laufenden Matches
Die Admin-Übersicht zeigt pro Docker-Host belegte und freie Plätze und die Matches, die dort laufen. Ohne konfigurierte Hosts bleibt die Karte aus.
This commit is contained in:
1 parent
c1c9250126
commit
91f979945e
6 files changed
+81
-1
No files matched your search
@@ -248,6 +248,14 @@ export class DockerHostPool {
|
||||
return free;
|
||||
}
|
||||
|
||||
/** Auslastung pro Host: Anzahl Port-Paare insgesamt und belegt. */
|
||||
hostStats() {
|
||||
return this.hosts.map((h) => {
|
||||
const total = Math.floor((h.portRangeEnd - h.portRangeStart + 1) / 2);
|
||||
return { name: h.name, publicHost: h.publicHost, total, used: total - this.freeSlots(h) };
|
||||
});
|
||||
}
|
||||
|
||||
getUsedPorts(publicHost) {
|
||||
return this.depsGetUsedPorts?.(publicHost) ?? new Set();
|
||||
}
|
||||
|
||||
@@ -160,6 +160,22 @@ export class ServerManager {
|
||||
this.service.changed(matchId);
|
||||
}
|
||||
|
||||
/** Auslastung der Docker-Hosts mit den Matches, die dort laufen. Leer, wenn der Adapter keine Hosts kennt. */
|
||||
hostUsage() {
|
||||
if (!this.adapter.hostStats) return [];
|
||||
const rows = this.db.prepare(`
|
||||
SELECT s.host, s.status, m.id AS match_id, m.team_a_name, m.team_b_name
|
||||
FROM servers s JOIN matches m ON m.id = s.match_id
|
||||
WHERE s.status != 'stopped' AND s.host IS NOT NULL
|
||||
`).all();
|
||||
return this.adapter.hostStats().map((h) => ({
|
||||
...h,
|
||||
matches: rows
|
||||
.filter((r) => r.host === h.publicHost)
|
||||
.map((r) => ({ id: r.match_id, title: `${r.team_a_name} vs. ${r.team_b_name}`, status: r.status })),
|
||||
}));
|
||||
}
|
||||
|
||||
/** Ports, die auf einem bestimmten Docker-Host belegt sind. */
|
||||
usedPortsOn(host) {
|
||||
const used = new Set();
|
||||
|
||||
Reference in new issue
Block a user