Repository navigation
feat(backend): add worker health and liveness telemetry - #48
Merged
whiteghost0001 merged 1 commit intoSep 14, 2026
Merged
whiteghost0001 merged 1 commit into
whiteghost0001 merged 1 commit into
Conversation
Background worker daemons (settlement, reservation cleanup, reconciliation) previously ran with no liveness signal, so a stalled or deadlocked worker looked identical to a healthy idle one to the orchestrator. This adds WorkerHealthTelemetryService, an in-process telemetry module tracking worker startup/shutdown, per-daemon sweep heartbeats, active job count, and distributed-lock acquisition failures, plus a standalone GET /health liveness server (default port 4001) returning 200 for healthy workers and 503 for stalled/stopped/not-started states. The snapshot payload contains no secrets or credentials. Closes LuminaRail#43 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #43
Summary
Background worker daemons (settlement, reservation cleanup, reconciliation) previously ran with no liveness signal — a stalled or deadlocked worker looked identical to a healthy idle one to the orchestrator. This PR adds heartbeat liveness telemetry and an HTTP health endpoint so Render can detect stalled workers instantly.
Implementation
WorkerHealthTelemetryService(src/infrastructure/telemetry/worker-health-telemetry.service.ts): in-process telemetry singleton tracking:DistributedLockService.acquire)WorkerLivenessServer(src/infrastructure/telemetry/worker-liveness.server.ts): dependency-free standalone HTTP server exposingGET /health:200— healthy (running with at least one fresh sweep heartbeat; distinguishes a healthy idle worker from a stalled one)503— stalled (no fresh sweep withinWORKER_LIVENESS_MAX_SWEEP_AGE_MS), stopped, or not startedsrc/worker.ts): lifecycle heartbeats on start/stop, per-daemon sweep heartbeat recording with per-daemon error isolation (one failing daemon no longer hides the others' heartbeats; errors aggregate to the existingWORKER_LOOP_ERRORaudit path), liveness server start/stop, and port-conflict resilience.src/config/index.ts): new validated env vars —WORKER_LIVENESS_ENABLED(defaulttrue),WORKER_LIVENESS_PORT(default4001),WORKER_LIVENESS_MAX_SWEEP_AGE_MS(default120000).Security
secret/password/token/seed/apikey/privatesubstrings, allowlisted top-level keys).Testing
tests/workers/worker-health-telemetry.test.ts(18 tests) covering:NOT_STARTED→STALLED→HEALTHY→STALLED(heartbeat staleness) →STOPPEDHEALTHYvs stalled worker503tests/settlements/worker-concurrency.test.tscaused by missingSTELLAR_SETTLEMENT_SIGNER_SECRET_KEYin the local environment (verified identical on the unmodified base commit; CI supplies its own env).npm run type-check,npm run lint, andnpm run buildall pass.Ops rollout note
Render worker service can point its health check at
:4001/healthonceWORKER_LIVENESS_PORTis exposed (env vars documented in.env.example).