Files
PaperClipAI/server/src/routes/liveness.ts
T
Devin FoleyandPaperclip a0651c96f8 Add database-free process liveness probes (#16101)
Expose process liveness without database or credential queries while preserving hostname and runtime identity guards. Deep health and sleep/wake readiness checks retain their existing behavior.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-10-13 07:43:46 -07:00

21 lines
886 B
TypeScript

import { Router, type RequestHandler } from "express";
import { getServerInfoSnapshot, type ServerInfoSnapshot } from "../server-info.js";
import { getStartupRecoveryState } from "../startup-recovery-state.js";
/** Routine probes report process readiness without auth, SQL, or provider I/O.
* Database readiness and signed bootstrap remain on /api/health. */
export function livenessRoutes(serverInfo: ServerInfoSnapshot = getServerInfoSnapshot()) {
const router = Router();
const commit = serverInfo.git.available ? serverInfo.git.fullSha : null;
const respond: RequestHandler = (_req, res) => {
const ready = getStartupRecoveryState().phase === "ready";
res.set("Cache-Control", "no-store").status(ready ? 200 : 503).json({
status: ready ? "ok" : "starting",
commit,
});
};
router.head("/", respond);
router.get("/", respond);
return router;
}