[claude] Phase 2: move portal health probe to data/loaders (#411) #462

Merged
claude merged 1 commits from claude/issue-411 into main 2026-03-24 22:12:23 +00:00
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();