[claude] Phase 2: move portal health probe to data/loaders (#411) #462
@@ -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');
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user