Milestone (a): project skeleton and OIDC login
- Next.js 16 + Tailwind + shadcn/ui skeleton - Auth.js v5 generic OIDC (Pocket ID, PKCE) with optional group gate - proxy.ts gates all pages and API routes - Drizzle schema (models, files, jobs, logs, worker state) on SQLite/libsql - Worker skeleton: migrations, interrupted-job recovery, heartbeat Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
891e496157
47 files changed
+14945
No files matched your search
@@ -0,0 +1,28 @@
|
||||
import "server-only";
|
||||
import { eq } from "drizzle-orm";
|
||||
import { db } from "@/lib/db/client";
|
||||
import { workerState } from "@/lib/db/schema";
|
||||
|
||||
/** The worker writes a heartbeat every 5s; after this long without one we call it offline. */
|
||||
const OFFLINE_AFTER_MS = 20_000;
|
||||
|
||||
export type WorkerStatus = {
|
||||
online: boolean;
|
||||
heartbeatAt: string | null;
|
||||
hfVersion: string | null;
|
||||
};
|
||||
|
||||
export async function getWorkerStatus(): Promise<WorkerStatus> {
|
||||
try {
|
||||
const row = await db().query.workerState.findFirst({ where: eq(workerState.id, "worker") });
|
||||
if (!row) return { online: false, heartbeatAt: null, hfVersion: null };
|
||||
return {
|
||||
online: Date.now() - row.heartbeatAt.getTime() < OFFLINE_AFTER_MS,
|
||||
heartbeatAt: row.heartbeatAt.toISOString(),
|
||||
hfVersion: row.hfVersion,
|
||||
};
|
||||
} catch {
|
||||
// Table missing (worker never ran migrations yet) or DB unavailable.
|
||||
return { online: false, heartbeatAt: null, hfVersion: null };
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user