Skip to content

Commit

Permalink
healthcheck with no db calls
Browse files Browse the repository at this point in the history
  • Loading branch information
jgravois committed Sep 22, 2024
1 parent 9ef8c53 commit e2cb90f
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions app/routes/healthcheck.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
// learn more: https://fly.io/docs/reference/configuration/#services-http_checks
import type { LoaderFunctionArgs } from "@remix-run/node";
// import type { LoaderFunctionArgs } from "@remix-run/node";

import { prisma } from "~/db.server";
// import { prisma } from "~/db.server";

export const loader = async ({ request }: LoaderFunctionArgs) => {
const host =
request.headers.get("X-Forwarded-Host") ?? request.headers.get("host");
export const loader = async (/*{ request }: LoaderFunctionArgs*/) => {
// const host =
// request.headers.get("X-Forwarded-Host") ?? request.headers.get("host");

try {
const url = new URL("/", `http://${host}`);
// const url = new URL("/", `http://${host}`);
// if we can connect to the database and make a simple query
// and make a HEAD request to ourselves, then we're good.
await Promise.all([
prisma.user.count(),
fetch(url.toString(), { method: "HEAD" }).then((r) => {
if (!r.ok) return Promise.reject(r);
}),
]);
// await Promise.all([
// prisma.user.count(),
// fetch(url.toString(), { method: "HEAD" }).then((r) => {
// if (!r.ok) return Promise.reject(r);
// }),
// ]);
return new Response("OK");
} catch (error: unknown) {
console.log("healthcheck ❌", { error });
Expand Down

0 comments on commit e2cb90f

Please sign in to comment.