mirror of
https://github.com/simstudioai/sim.git
synced 2026-01-30 09:18:01 -05:00
bugbot comment
This commit is contained in:
@@ -17,15 +17,21 @@ interface Logger {
|
||||
export function createHttpHandler(roomManager: IRoomManager, logger: Logger) {
|
||||
return async (req: IncomingMessage, res: ServerResponse) => {
|
||||
if (req.method === 'GET' && req.url === '/health') {
|
||||
const connections = await roomManager.getTotalActiveConnections()
|
||||
res.writeHead(200, { 'Content-Type': 'application/json' })
|
||||
res.end(
|
||||
JSON.stringify({
|
||||
status: 'ok',
|
||||
timestamp: new Date().toISOString(),
|
||||
connections,
|
||||
})
|
||||
)
|
||||
try {
|
||||
const connections = await roomManager.getTotalActiveConnections()
|
||||
res.writeHead(200, { 'Content-Type': 'application/json' })
|
||||
res.end(
|
||||
JSON.stringify({
|
||||
status: 'ok',
|
||||
timestamp: new Date().toISOString(),
|
||||
connections,
|
||||
})
|
||||
)
|
||||
} catch (error) {
|
||||
logger.error('Error in health check:', error)
|
||||
res.writeHead(503, { 'Content-Type': 'application/json' })
|
||||
res.end(JSON.stringify({ status: 'error', message: 'Health check failed' }))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user