PR 4 du chantier admin. Board de sante temps reel des dependances.
- POST /internal/tech-steps/heartbeat (requireInternalWorker) ->
recordWorkerHeartbeat : upsert WorkerHeartbeat (cle fixe
"tech-step-llm-worker"), lastRunAt/lastResult pour un ping "job".
Schema workerHeartbeatSchema dans packages/shared.
- services/tech-step-llm-worker : api-client.postHeartbeat (best-effort,
ne throw jamais) appele au boot (index.ts), a chaque tick et apres
chaque job (scheduler.ts, avec job/ok/counts).
- admin-monitoring.service.ts + GET /admin/monitoring (requireAdmin) :
sonde active bornee (~2 s) de Postgres (SELECT 1), l'API (uptime/RSS),
tech-step-intent-service (/health), et le worker via son heartbeat.
Statut up/degraded/down/unknown ; une sonde down ne casse ni les autres
ni l'endpoint. Seuils worker : > 8 j degraded, > 21 j down.
- MonitoringView / ServiceHealthView dans packages/shared.
- Front : MonitoringPage (grille de cartes coloree par statut, re-poll
15 s), logique pure monitoring.ts, i18n admin.monitoring.*,
AdminApiClient.getMonitoring.
- Tests : Mocha admin-monitoring.test.ts (heartbeat 401/400/upsert
job+boot ; GET /admin/monitoring 401, board 4 cibles, worker unknown
sans heartbeat puis up apres) ; Cypress monitoring.cy.ts (2 verts).
Worker mocha : 6/6 toujours verts.
- specs/backend-architecture.md : section monitoring. .gitignore :
apps/admin-web/cypress/{screenshots,videos,downloads}.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
25 lines
838 B
TypeScript
25 lines
838 B
TypeScript
import { postHeartbeat } from "./api-client.js";
|
|
import { env } from "./config.js";
|
|
import { runOnce, startScheduler } from "./scheduler.js";
|
|
|
|
// Tell `apps/api` we're alive as early as possible — before either the
|
|
// one-shot run or the cron loop — so the admin monitoring board reflects a
|
|
// fresh deploy immediately, not only after the first scheduled fire.
|
|
await postHeartbeat({ event: "boot" });
|
|
|
|
/**
|
|
* Entrypoint — `RUN_ONCE=true` runs both jobs a single time and exits
|
|
* (manual/CI-triggered invocation, `pnpm start`), otherwise starts the
|
|
* long-lived cron loop (the container's normal mode, see `Dockerfile`).
|
|
*/
|
|
if (env.RUN_ONCE) {
|
|
try {
|
|
await runOnce();
|
|
process.exit(0);
|
|
} catch (err) {
|
|
console.error("[tech-step-llm-worker] run failed:", err);
|
|
process.exit(1);
|
|
}
|
|
} else {
|
|
startScheduler();
|
|
}
|