Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. 🔥
TypeScript aiai-agentsai-crawlerai-scrapingai-searchcrawlerdata-extractionhtml-to-markdownllmmarkdownscraperscrapingweb-crawlerweb-dataweb-data-extractionweb-scraperweb-scrapingweb-searchwebscraping
feat(api): serve health probes at /health/liveness and /health/readiness (#5613)
Gergő Móricz48a3f1bff714
diff --git a/apps/api/src/controllers/v0/liveness.ts b/apps/api/src/controllers/health.tssimilarity index 57%rename from apps/api/src/controllers/v0/liveness.tsrename to apps/api/src/controllers/health.tsindex 8ff1a96f9..53e523227 100644--- a/apps/api/src/controllers/v0/liveness.ts+++ b/apps/api/src/controllers/health.ts@@ -4,3 +4,8 @@ export async function livenessController(req: Request, res: Response) {//TODO: add checks if the application is live and healthy like checking the redis connectionres.status(200).json({ status: "ok" });}++export async function readinessController(req: Request, res: Response) {+ // TODO: add checks when the application is ready to serve traffic+ res.status(200).json({ status: "ok" });+}diff --git a/apps/api/src/controllers/v0/readiness.ts b/apps/api/src/controllers/v0/readiness.tsdeleted file mode 100644index cdb1f02c3..000000000--- a/apps/api/src/controllers/v0/readiness.ts+++ /dev/null@@ -1,6 +0,0 @@-import { Request, Response } from "express";--export async function readinessController(req: Request, res: Response) {- // TODO: add checks when the application is ready to serve traffic- res.status(200).json({ status: "ok" });-}diff --git a/apps/api/src/index.ts b/apps/api/src/index.tsindex a6d667fdf..fa18cf619 100644--- a/apps/api/src/index.ts+++ b/apps/api/src/index.ts@@ -12,6 +12,7 @@ import {getFirebillTrackRetryQueue,} from "./services/queue-service";import { v0Router } from "./routes/v0";+import { livenessController, readinessController } from "./controllers/health";import { startNodeRuntimeMetrics } from "./lib/node-runtime-metrics";import os from "os";import { logger } from "./lib/logger";@@ -140,6 +141,9 @@ app.get("/e2e-test", (_, res) => {res.status(200).send("OK");});+app.get("/health/liveness", livenessController);+app.get("/health/readiness", readinessController);+// register routerapp.use(v0Router);app.use("/v1", v1Router);diff --git a/apps/api/src/routes/v0.ts b/apps/api/src/routes/v0.tsindex 550a7b8b6..99fc70b11 100644--- a/apps/api/src/routes/v0.ts+++ b/apps/api/src/routes/v0.ts@@ -5,8 +5,7 @@ import { scrapeController } from "../../src/controllers/v0/scrape";import { searchController } from "../../src/controllers/v0/search";import { crawlCancelController } from "../../src/controllers/v0/crawl-cancel";import { keyAuthController } from "../../src/controllers/v0/keyAuth";-import { livenessController } from "../controllers/v0/liveness";-import { readinessController } from "../controllers/v0/readiness";+import { livenessController, readinessController } from "../controllers/health";import { deprecationMiddleware } from "../lib/deprecations";export const v0Router = express.Router();@@ -38,6 +37,6 @@ v0Router.post(searchController,);-// Health/Probe routes+// Health/Probe routes, kept as aliases of /health/* in index.tsv0Router.get("/v0/health/liveness", livenessController);v0Router.get("/v0/health/readiness", readinessController);diff --git a/examples/kubernetes/cluster-install/README.md b/examples/kubernetes/cluster-install/README.mdindex 7e6e63e1e..62265ded5 100644--- a/examples/kubernetes/cluster-install/README.md+++ b/examples/kubernetes/cluster-install/README.md@@ -79,7 +79,7 @@ In another terminal, check API reachability:```bashcurl --fail --silent --show-error \- http://localhost:3002/v0/health/readiness+ http://localhost:3002/health/readiness```Then test the end-to-end scraping path:diff --git a/examples/kubernetes/cluster-install/api.yaml b/examples/kubernetes/cluster-install/api.yamlindex 91f120507..4cd208e86 100644--- a/examples/kubernetes/cluster-install/api.yaml+++ b/examples/kubernetes/cluster-install/api.yaml@@ -42,7 +42,7 @@ spec:cpu: "2000m"livenessProbe:httpGet:- path: /v0/health/liveness+ path: /health/livenessport: 3002initialDelaySeconds: 30periodSeconds: 30@@ -51,7 +51,7 @@ spec:failureThreshold: 3readinessProbe:httpGet:- path: /v0/health/readiness+ path: /health/readinessport: 3002initialDelaySeconds: 30periodSeconds: 30diff --git a/examples/kubernetes/firecrawl-helm/README.md b/examples/kubernetes/firecrawl-helm/README.mdindex d48218e0b..24be65549 100644--- a/examples/kubernetes/firecrawl-helm/README.md+++ b/examples/kubernetes/firecrawl-helm/README.md@@ -94,7 +94,7 @@ In another terminal, check reachability and one scrape:```bashcurl --fail --silent --show-error \- http://localhost:3002/v0/health/readiness+ http://localhost:3002/health/readiness``````bashdiff --git a/examples/kubernetes/firecrawl-helm/templates/deployment.yaml b/examples/kubernetes/firecrawl-helm/templates/deployment.yamlindex 602fdf057..f3075620d 100644--- a/examples/kubernetes/firecrawl-helm/templates/deployment.yaml+++ b/examples/kubernetes/firecrawl-helm/templates/deployment.yaml@@ -45,7 +45,7 @@ spec:{{- end }}livenessProbe:httpGet:- path: /v0/health/liveness+ path: /health/livenessport: {{ .Values.service.api.port }}initialDelaySeconds: 30periodSeconds: 30@@ -54,7 +54,7 @@ spec:failureThreshold: 3readinessProbe:httpGet:- path: /v0/health/readiness+ path: /health/readinessport: {{ .Values.service.api.port }}initialDelaySeconds: 30periodSeconds: 30