feat(deploy): konteyner başlatma adımı ve sağlık kontrolünde replica set

- scripts/bootstrap.ts: replica set/PRIMARY kontrolü, migration'lar, production'da ilk admin
- esbuild ile tek dosya (dist/bootstrap.mjs), docker-entrypoint.sh ile uygulamadan önce
- /api/health yanıtında replicaSet alanı; healthcheck başlangıç payı 60 sn

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-07 02:13:10 +03:00
parent 42561b570a
commit 7d7dd61c60
9 changed files with 80 additions and 5 deletions
+12 -1
View File
@@ -1,5 +1,5 @@
import { connection } from "next/server";
import { pingDb } from "@/lib/db/mongo";
import { getDb, pingDb } from "@/lib/db/mongo";
import { APP_COMMIT, APP_VERSION } from "@/lib/version";
/**
@@ -10,10 +10,21 @@ export async function GET() {
// Cache Components açıkken GET handler'ı build'de prerender edilmesin.
await connection();
const dbOk = await pingDb();
// Transaction'lar için replica set şart; adı yoksa (standalone) null.
let replicaSet: string | null = null;
if (dbOk) {
try {
const hello = await getDb().admin().command({ hello: 1 }, { timeoutMS: 2_000 });
replicaSet = typeof hello.setName === "string" ? hello.setName : null;
} catch {
replicaSet = null;
}
}
return Response.json(
{
status: dbOk ? "ok" : "degraded",
db: dbOk ? "ok" : "unreachable",
replicaSet,
version: APP_VERSION,
commit: APP_COMMIT,
time: new Date().toISOString(),