chore(ops): strip redundant force-dynamic and probe Redis in ops health
CI / check (push) Successful in 25s
CI / release (push) Skipped
CI / deploy (push) Successful in 1m8s

Co-authored-by: Cursor <[email protected]>
This commit is contained in:
SimoandCursor committed 2026-07-30 21:33:40 +02:00
1 parent 3e584aadaf
commit 3ac5d6f4f6
60 files changed
+95 -114

No files matched your search

+18 -3
View File
@@ -1,21 +1,25 @@
import "server-only";
import { env } from "@/env";
import { prisma } from "@/lib/prisma";
import { redis } from "@/lib/redis";
import { rcon } from "@/lib/services/rcon";
export type OpsHealth = {
dbOk: boolean;
dbLatencyMs: number;
/** null = REDIS_URL unset (optional); true/false = probe result */
redisOk: boolean | null;
emulatorOk: boolean;
onlineUsers: number;
};
/**
* Shared DB + emulator health probe for CommandoCentrum, DevOps, and APIs.
* Emulator = real RCON `ping` (same semantics as CommandoCentrum /public health).
* Shared DB + Redis + emulator health probe for CommandoCentrum, DevOps, and APIs.
* Semantics match `/api/health` for Redis (null when not configured).
*/
export async function fetchOpsHealth(): Promise<OpsHealth> {
const [db, emulatorOk, onlineUsers] = await Promise.all([
const [db, redisOk, emulatorOk, onlineUsers] = await Promise.all([
(async () => {
try {
const start = Date.now();
@@ -25,6 +29,16 @@ export async function fetchOpsHealth(): Promise<OpsHealth> {
return { dbOk: false, dbLatencyMs: 0 };
}
})(),
(async (): Promise<boolean | null> => {
if (!env.REDIS_URL) return null;
if (!redis) return false;
try {
const pong = await redis.ping();
return pong === "PONG";
} catch {
return false;
}
})(),
rcon.send("ping", null).catch(() => false),
prisma.user.count({ where: { online: "1" } }).catch(() => 0),
]);
@@ -32,6 +46,7 @@ export async function fetchOpsHealth(): Promise<OpsHealth> {
return {
dbOk: db.dbOk,
dbLatencyMs: db.dbLatencyMs,
redisOk,
emulatorOk: Boolean(emulatorOk),
onlineUsers,
};