Fehler-Handling

This commit is contained in:
chk
2026-06-08 18:54:40 +02:00
parent 204e050ae4
commit 71f227ace1
2 changed files with 46 additions and 4 deletions

View File

@@ -9,6 +9,8 @@ services:
- WSS_VIDEO_DRIVER=wss://localhost:8448
- WSS_URL=wss://appRobot_Driver:2095
- HTTPS_PORT=2093
- WEBCAM_URL=http://appRobotWebcam:8444
- BODYTRACKER_URL=http://appRobotBodyTracker:8446
ports:
- "2093:2093"
depends_on:

View File

@@ -140,8 +140,48 @@ app.post('/api/estimate', async (req, res) => {
}
});
app.listen(PORT, () => {
console.log(`appRobotHoming backend listening on port ${PORT}`);
console.log(`WEBCAM_URL=${WEBCAM_URL || '<lokal>'}`);
console.log(`BODYTRACKER_URL=${BODYTRACKER_URL || '<nicht konfiguriert>'}`);
async function checkServiceReachability(name, url) {
try {
const controller = new AbortController();
const timeout = setTimeout(() => controller.abort(), 5000);
const res = await fetch(url, { signal: controller.signal });
clearTimeout(timeout);
if (!res.ok) {
console.warn(`${name} ist nicht vollständig erreichbar (${res.status}) unter ${url}`);
return false;
}
console.log(`${name} erreichbar unter ${url}`);
return true;
} catch (err) {
console.warn(`${name} konnte nicht erreicht werden unter ${url}:`, err.message || err);
return false;
}
}
async function startServer() {
if (WEBCAM_URL) {
await checkServiceReachability('WEBCAM_URL', new URL('/health', WEBCAM_URL).toString());
}
if (BODYTRACKER_URL) {
await checkServiceReachability('BODYTRACKER_URL', new URL('/v1/health', BODYTRACKER_URL).toString());
}
app.listen(PORT, () => {
console.log(`appRobotHoming backend listening on port ${PORT}`);
console.log(`WEBCAM_URL=${WEBCAM_URL || '<lokal>'}`);
console.log(`BODYTRACKER_URL=${BODYTRACKER_URL || '<nicht konfiguriert>'}`);
});
}
startServer().catch((err) => {
console.error('Fehler beim Starten des Servers:', err);
console.log('Starte trotzdem den Server weiter...');
app.listen(PORT, () => {
console.log(`appRobotHoming backend listening on port ${PORT}`);
console.log(`WEBCAM_URL=${WEBCAM_URL || '<lokal>'}`);
console.log(`BODYTRACKER_URL=${BODYTRACKER_URL || '<nicht konfiguriert>'}`);
});
});