usaco: let running jobs finish on stop, add a Claude budget
Test and deploy / test (push) Successful in 1m20s
Test and deploy / deploy (push) Successful in 1m12s

The site now waits up to 5 minutes on SIGTERM for running Claude jobs, so
stop_grace_period must be longer than Docker's 10s default.
USACO_CLAUDE_MONTHLY_BUDGET caps its estimated monthly Claude spend.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
2026-10-23 22:10:08 +01:00
co-authored by Claude Opus 5.5
parent acf21c69c2
commit 263e16b70d
2 changed files with 16 additions and 2 deletions
+11 -2
View File
@@ -568,10 +568,17 @@ services:
# USACO_OPENAI_API_KEY to transcribe, and keep the audio in Garage's
# private usaco-audio bucket when USACO_S3_* is set (the site refuses to
# start with only some S3_* set, so all five go together or not at all:
# the blank-key case blanks the rest). ./usaco-data holds only
# that clone, so deleting it is safe; the image runs as uid 1000, so the
# the blank-key case blanks the rest). USACO_CLAUDE_MONTHLY_BUDGET (dollars,
# blank for none) stops new Claude jobs once a month's estimated spend
# reaches it. ./usaco-data holds that clone, the background jobs' records
# and the Claude spend ledger; deleting it is safe (it re-clones) but loses
# any answer not yet committed. The image runs as uid 1000, so the
# directory must be owned by it.
#
# On stop it lets running Claude jobs finish for up to SHUTDOWN_GRACE (5m
# by default) before exiting, so stop_grace_period must be longer than
# that, or Docker kills it mid-job.
#
# Same explicit `environment:` list as jobs. Like the tracker it has no
# login: visitors see solved problems, and AUTH_VALIDATE_URL decides who
# is the admin from the visitor's cookies.
@@ -579,6 +586,7 @@ services:
image: adam-french.co.uk/adamf/usaco:${USACO_IMAGE_TAG:-latest}
container_name: usaco
restart: always
stop_grace_period: 6m
depends_on:
- gitea
- usaco-runner
@@ -592,6 +600,7 @@ services:
- AUTH_VALIDATE_URL=http://${BACKEND_HOST}:${BACKEND_PORT}/auth/validate-admin
- CLAUDE_API_KEY=${CLAUDE_API_KEY:-}
- CLAUDE_MODEL=${USACO_CLAUDE_MODEL:-}
- CLAUDE_MONTHLY_BUDGET=${USACO_CLAUDE_MONTHLY_BUDGET:-}
- TRANSCRIBE_API_KEY=${USACO_OPENAI_API_KEY:-}
- S3_ACCESS_KEY_ID=${USACO_S3_ACCESS_KEY_ID:-}
- S3_SECRET_ACCESS_KEY=${USACO_S3_SECRET_ACCESS_KEY:-}