Keep site jobs across restarts, meter Claude spend, harden admin routes
- internal/jobs replaces explain.Jobs: one registry for every kind of background job, with records in DATA_DIR/jobs. A job's draft is written before its commit, so a failed commit can be saved again (POST /jobs/<kind>/<key>/save) and a restart mid-commit resumes it, without paying Claude twice. - Graceful shutdown: SIGTERM stops new jobs and waits SHUTDOWN_GRACE for running ones while still serving the pages that poll them. - internal/usage records every Claude call's tokens and estimated cost in DATA_DIR/usage.jsonl; CLAUDE_MONTHLY_BUDGET refuses new jobs (429) once a month reaches it. The stats page shows the admin the spend. - auth.SameOrigin refuses cross-origin writes to admin routes. - The LeetCode importer runs the clone's script without the server's secrets in its environment. - A sync that leaves HEAD where it was skips the re-index. - docs_test.go checks README's route table against the routes, and the CLI page against the root README's commands. - The repo is going private: Gitea links on the site are admin-only. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
+9
-1
@@ -5,12 +5,16 @@
|
||||
# --- Core -------------------------------------------------------------------
|
||||
# URL prefix everything is served under. The SPA is built for /usaco.
|
||||
BASE_PATH=
|
||||
# The clone lives in $DATA_DIR/repo (default /data).
|
||||
# The clone lives in $DATA_DIR/repo (default /data), beside the job records
|
||||
# ($DATA_DIR/jobs) and the Claude spend ledger ($DATA_DIR/usage.jsonl).
|
||||
DATA_DIR=
|
||||
# Listen port (default 8080).
|
||||
PORT=
|
||||
# "true" enables gin debug logging, and is required for AUTH_MODE=dev.
|
||||
DEV_MODE=
|
||||
# How long a SIGTERM waits for running jobs before the server exits, a Go
|
||||
# duration. Default 5m; the container's stop_grace_period must be longer.
|
||||
SHUTDOWN_GRACE=
|
||||
|
||||
# --- Git --------------------------------------------------------------------
|
||||
# What to clone. Production: http://gitea:3000/adamf/usaco.git (Gitea on the
|
||||
@@ -47,6 +51,10 @@ AUTH_VALIDATE_URL=
|
||||
CLAUDE_API_KEY=
|
||||
# Model for explanations (default claude-opus-5-5).
|
||||
CLAUDE_MODEL=
|
||||
# Monthly cap on the estimated Claude spend, in dollars (e.g. 20). Once a
|
||||
# calendar month (UTC) reaches it, new Claude jobs are refused until the 1st.
|
||||
# Blank: no cap; spend is still recorded and shown on the stats page.
|
||||
CLAUDE_MONTHLY_BUDGET=
|
||||
|
||||
# --- Recording reviews ------------------------------------------------------
|
||||
# A review needs CLAUDE_API_KEY and a transcriber: anything that speaks
|
||||
|
||||
Reference in New Issue
Block a user