mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-06-09 17:31:19 +00:00
🩺 feat: Add Explicit Readiness Endpoints (#13212)
This commit is contained in:
parent
679672ad15
commit
9cb650d1d8
1 changed files with 11 additions and 0 deletions
|
|
@ -54,6 +54,7 @@ const host = HOST || 'localhost';
|
|||
const trusted_proxy = Number(TRUST_PROXY) || 1; /* trust first proxy by default */
|
||||
|
||||
const app = express();
|
||||
let serverReady = false;
|
||||
|
||||
const startServer = async () => {
|
||||
const { metricsMiddleware, metricsRouter } = createMetrics();
|
||||
|
|
@ -114,6 +115,13 @@ const startServer = async () => {
|
|||
}
|
||||
|
||||
app.get('/health', (_req, res) => res.status(200).send('OK'));
|
||||
app.get('/livez', (_req, res) => res.status(200).send('OK'));
|
||||
app.get('/readyz', (_req, res) => {
|
||||
if (!serverReady) {
|
||||
return res.status(503).send('NOT_READY');
|
||||
}
|
||||
return res.status(200).send('OK');
|
||||
});
|
||||
|
||||
/* Middleware */
|
||||
app.use(metricsMiddleware);
|
||||
|
|
@ -279,7 +287,10 @@ const startServer = async () => {
|
|||
if (inspectFlags || isEnabled(process.env.MEM_DIAG)) {
|
||||
memoryDiagnostics.start();
|
||||
}
|
||||
serverReady = true;
|
||||
logger.info('Server readiness checks passing.');
|
||||
} catch (initErr) {
|
||||
serverReady = false;
|
||||
logger.error('Post-listen initialization failed:', initErr);
|
||||
process.exit(1);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue