Preserve verified health when provisioning completes
This commit is contained in:
@@ -9,6 +9,7 @@ import type { RconFailure } from '../integrations/rcon.js';
|
||||
import { setServerFields, type ServerRow } from '../fleet/servers.js';
|
||||
import { inspectForMonitoring, rconForMonitoring, prepareMonitoringRcon, monitoringStatus, monitoringStatusWriter, monitoringIdentity, MonitoringChangedError, MonitoringSkippedError } from '../fleet/health-observations.js';
|
||||
import { serverObservation } from '../fleet/status.js';
|
||||
import { successfulStatusFields, activityFields } from '../fleet/status-updates.js';
|
||||
import { STATUS_REFRESH_MS } from '../../server-freshness.js';
|
||||
import { recordMetrics } from '../fleet/metrics.js';
|
||||
import { selectedZombieMap } from '../../map-aliases.js';
|
||||
@@ -220,13 +221,7 @@ async function refreshServerStatus(server: string, snapshot: MonitoringSnapshot,
|
||||
updates.last_reply_snippet = result.rawReply ?? null;
|
||||
if (result.ok) {
|
||||
capacity = result.status.capacity ?? null;
|
||||
updates.last_players = result.status.players;
|
||||
updates.last_map = result.status.map;
|
||||
updates.last_gametype = result.status.gametype;
|
||||
updates.last_roster = JSON.stringify(result.status.roster);
|
||||
updates.last_seen_at = now;
|
||||
updates.last_error = null;
|
||||
updates.rcon_failures = 0;
|
||||
Object.assign(updates, successfulStatusFields(result, now));
|
||||
} else {
|
||||
// Only distinct accepted checks in the current lifecycle count.
|
||||
// Skipped/superseded checks return above without changing the streak.
|
||||
@@ -247,18 +242,7 @@ async function refreshServerStatus(server: string, snapshot: MonitoringSnapshot,
|
||||
}
|
||||
const current = { ...(snapshot.get(srv.name)?.server ?? srv), ...updates } as ServerRow;
|
||||
const status = snapshot.observe(current);
|
||||
// Occupancy timers and match clearing follow the same source as the UI.
|
||||
if (status.health === 'online' && status.last_players !== null) {
|
||||
if (status.last_players > 0) {
|
||||
updates.active_since = current.active_since ?? status.last_seen_at;
|
||||
updates.inactive_since = null;
|
||||
} else {
|
||||
updates.active_since = null;
|
||||
updates.inactive_since = current.inactive_since ?? status.last_seen_at;
|
||||
updates.game_started_at = null;
|
||||
updates.game_ended_at = null;
|
||||
}
|
||||
}
|
||||
Object.assign(updates, activityFields(current, status));
|
||||
flush();
|
||||
return capacity;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user