docker healthcheck api thingy

This commit is contained in:
legop3
2026-09-15 12:33:45 -04:00
parent bdb32d13ac
commit 5d4f7fe5cc
4 changed files with 75 additions and 1 deletions
+14
View File
@@ -16,6 +16,20 @@ app.use(morgan('dev'));
*/
app.use(PUBLIC_MEDIA_PREFIX, createMediaMtxProxy({ logger }));
app.use(express.json());
/*
Docker and the later lifecycle controller need one stable readiness result,
but they do not need administrator credentials or application details. Load
the health service only when the route is called so the global HTTP module
remains safe to initialize before the service graph during bootstrap.
*/
app.get('/health', async (_req, res) => {
const { getContainerHealth } = require('../services/healthService');
const health = await getContainerHealth();
res.status(health.healthy ? 200 : 503).json({
status: health.healthy ? 'healthy' : 'unhealthy',
checks: health.checks,
});
});
app.use(express.static(config.staticDir, { index: false }));
const httpServer = http.createServer(app);