Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Webservice healthcheck #144

Merged
merged 3 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion apps/webservice/src/app/api/healthz/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
import { NextResponse } from "next/server";
import IORedis from "ioredis";

import { sql } from "@ctrlplane/db";
import { db } from "@ctrlplane/db/client";

import { env } from "~/env";

export const GET = async () => {
try {
await new IORedis(env.REDIS_URL).ping();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we want to set max retries to null for the health check (because apparently it waits forever), so just using the default which is 20

await db.execute(sql`SELECT 1`);
} catch (error) {
return NextResponse.json({ status: "error", error }, { status: 500 });
}

export const GET = () => {
return NextResponse.json({ status: "ok" });
};
1 change: 1 addition & 0 deletions apps/webservice/src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const env = createEnv({
GITHUB_BOT_PRIVATE_KEY: z.string().optional(),
GITHUB_WEBHOOK_SECRET: z.string().optional(),
BASE_URL: z.string(),
REDIS_URL: z.string(),
OTEL_SAMPLER_RATIO: z.number().optional().default(1),
},

Expand Down
Loading