Skip to content

Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. 🔥

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.ts
similarity index 57%
rename from apps/api/src/controllers/v0/liveness.ts
rename to apps/api/src/controllers/health.ts
index 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 connection
res.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.ts
deleted file mode 100644
index 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.ts
index 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 router
app.use(v0Router);
app.use("/v1", v1Router);
diff --git a/apps/api/src/routes/v0.ts b/apps/api/src/routes/v0.ts
index 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.ts
v0Router.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.md
index 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:
```bash
curl --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.yaml
index 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/liveness
port: 3002
initialDelaySeconds: 30
periodSeconds: 30
@@ -51,7 +51,7 @@ spec:
failureThreshold: 3
readinessProbe:
httpGet:
- path: /v0/health/readiness
+ path: /health/readiness
port: 3002
initialDelaySeconds: 30
periodSeconds: 30
diff --git a/examples/kubernetes/firecrawl-helm/README.md b/examples/kubernetes/firecrawl-helm/README.md
index 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:
```bash
curl --fail --silent --show-error \
- http://localhost:3002/v0/health/readiness
+ http://localhost:3002/health/readiness
```
```bash
diff --git a/examples/kubernetes/firecrawl-helm/templates/deployment.yaml b/examples/kubernetes/firecrawl-helm/templates/deployment.yaml
index 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/liveness
port: {{ .Values.service.api.port }}
initialDelaySeconds: 30
periodSeconds: 30
@@ -54,7 +54,7 @@ spec:
failureThreshold: 3
readinessProbe:
httpGet:
- path: /v0/health/readiness
+ path: /health/readiness
port: {{ .Values.service.api.port }}
initialDelaySeconds: 30
periodSeconds: 30