[claude] Phase 2: move portal health probe to data/loaders (#411) (#462)
Some checks failed
Deploy Nexus / deploy (push) Failing after 7s
Staging Smoke Test / smoke-test (push) Failing after 1s

This commit was merged in pull request #462.
This commit is contained in:
2026-03-24 22:12:22 +00:00
parent c0a673038b
commit 6db2871785
2 changed files with 21 additions and 15 deletions

View File

@@ -18,6 +18,25 @@ export async function fetchSoulMd() {
}
}
// --- Portal health probes ---
export async function checkPortalHealth(portals) {
for (const portal of portals) {
if (!portal.destination?.url) {
portal.status = 'offline';
continue;
}
try {
await fetch(portal.destination.url, {
mode: 'no-cors',
signal: AbortSignal.timeout(5000),
});
portal.status = 'online';
} catch {
portal.status = 'offline';
}
}
}
// --- portals.json ---
export async function fetchPortals() {
const res = await fetch('./portals.json');

View File

@@ -5,6 +5,7 @@ import { cloudMaterial } from './platform.js';
import { rebuildRuneRing } from './effects.js';
import { S } from './state.js';
import { fetchWeatherData } from './data/weather.js';
import { checkPortalHealth } from './data/loaders.js';
// === PORTAL HEALTH CHECKS ===
const PORTAL_HEALTH_CHECK_MS = 5 * 60 * 1000;
@@ -23,21 +24,7 @@ export function setWeatherPortalRefs(portals, portalGroup, rebuildGravityZones)
export async function runPortalHealthChecks() {
if (_portalsRef.length === 0) return;
for (const portal of _portalsRef) {
if (!portal.destination?.url) {
portal.status = 'offline';
continue;
}
try {
await fetch(portal.destination.url, {
mode: 'no-cors',
signal: AbortSignal.timeout(5000),
});
portal.status = 'online';
} catch {
portal.status = 'offline';
}
}
await checkPortalHealth(_portalsRef);
rebuildRuneRing();
if (_rebuildGravityZonesFn) _rebuildGravityZonesFn();