mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-09-18 18:40:47 -04:00
docker healthcheck api thingy
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user