fix(scheduler): self-healing 5-minute watchdog daemon, configurable stuck request recovery, and authenticated REST API - #253
Open
thehaven wants to merge 1 commit into
Conversation
…tuck request recovery, and authenticated REST API
thehaven
force-pushed
the
fix/scheduler-watchdog
branch
from
July 31, 2026 13:01
a377e98 to
ba207de
Compare
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.
Note
Disclosure: This pull request was developed with assistance from Google Antigravity / Gemini CLI (
gemini-cli) AI coding assistant. All implementation logic and unit tests (vitest100% passing) have been empirically verified in production container deployments.📦 Summary & Problem Solved
1. Self-Healing 5-Minute Scheduler Watchdog Daemon
src/lib/services/scheduler.service.ts) that monitors scheduled job execution freshness. If any cron job hasn't executed within its expected timeframe, the watchdog automatically re-queues and resumes execution without requiring container restarts.2. Configurable Stuck Request Recovery (Slow Torrent Safe)
searchingorprocessingdue to unhandled worker crashes remained stuck indefinitely, but hardcoded short timeouts could interrupt slow torrent downloads or long-running private tracker seeds.system.stuck_request_timeout_hours) and ENV (STUCK_REQUEST_TIMEOUT_HOURS) with a safe default threshold of 6 hours (and setting to0disables recovery completely).3. Authenticated REST API Endpoints & Self-Documentation
POST /api/admin/scheduler/trigger,GET /api/admin/scheduler/status) enforcingverifyAccessTokenJWT authentication andadminrole checks (401 Unauthorizedwhen unauthenticated). Integrated endpoints into the interactive/api-docsinterface.🔒 Authentication Usage Example
Endpoints require a Bearer token in the
Authorizationheader obtained via/api/auth/local/loginor via Admin API Tokens (rmab_...):🧪 Unit Test Verification