-
Notifications
You must be signed in to change notification settings - Fork 1.9k
feat: run scheduled maintenance endpoints in self-hosted deployments #2299
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -20,6 +20,10 @@ NEXTAUTH_SECRET= | |||||
| # Generate with: openssl rand -hex 32 | ||||||
| MEDIA_SERVER_WEBHOOK_SECRET= | ||||||
|
|
||||||
| # Secret the cap-cron service uses to call Cap Web's scheduled maintenance endpoints | ||||||
| # Generate with: openssl rand -hex 32 | ||||||
|
Comment on lines
+23
to
+24
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
These comments only restate the variable’s purpose and its standard generation command. This violates the repository directive to avoid code comments unless they preserve non-obvious context from a bug or complex investigation, so this requirement must be satisfied before merging.
Suggested change
Context Used: AGENTS.md (source) Prompt To Fix With AIThis is a comment left during a code review.
Path: docker-compose.coolify.env.example
Line: 23-24
Comment:
**Routine comments violate policy**
These comments only restate the variable’s purpose and its standard generation command. This violates the repository directive to avoid code comments unless they preserve non-obvious context from a bug or complex investigation, so this requirement must be satisfied before merging.
```suggestion
```
**Context Used:** AGENTS.md ([source](https://github.com/capsoftware/cap/blob/main/AGENTS.md))
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time! |
||||||
| CRON_SECRET= | ||||||
|
|
||||||
| # =================== | ||||||
| # DATABASE | ||||||
| # =================== | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,7 @@ services: | |
| DATABASE_ENCRYPTION_KEY: ${DATABASE_ENCRYPTION_KEY:-0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef} | ||
| NEXTAUTH_SECRET: ${NEXTAUTH_SECRET:-abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789} | ||
| MEDIA_SERVER_WEBHOOK_SECRET: ${MEDIA_SERVER_WEBHOOK_SECRET:-fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210} | ||
| CRON_SECRET: ${CRON_SECRET:-0f1e2d3c4b5a69780f1e2d3c4b5a69780f1e2d3c4b5a69780f1e2d3c4b5a6978} | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: Do not ship a predictable fallback secret for externally reachable maintenance endpoints A predictable compose fallback authenticates the new recovery and deletion endpoints if operators omit CRON_SECRET. Require a unique CRON_SECRET; do not provide a production compose fallback for this endpoint-authentication secret. AI prompt |
||
| CAP_AWS_ACCESS_KEY: ${MINIO_ROOT_USER:-cap-admin} | ||
| CAP_AWS_SECRET_KEY: ${MINIO_ROOT_PASSWORD:-cap-minio-pwd-456} | ||
| CAP_AWS_BUCKET: cap | ||
|
|
@@ -61,6 +62,48 @@ services: | |
| networks: | ||
| - cap-network | ||
|
|
||
| cap-cron: | ||
| container_name: cap-cron | ||
| image: curlimages/curl:8.22.0 | ||
| restart: unless-stopped | ||
| depends_on: | ||
| cap-web: | ||
| condition: service_healthy | ||
| environment: | ||
| CRON_SECRET: ${CRON_SECRET:-0f1e2d3c4b5a69780f1e2d3c4b5a69780f1e2d3c4b5a69780f1e2d3c4b5a6978} | ||
| CAP_WEB_INTERNAL_URL: http://cap-web:3000 | ||
| entrypoint: | ||
| - /bin/sh | ||
| - -c | ||
| - | | ||
| trap 'exit 0' TERM INT | ||
| run() { | ||
| mkdir "/tmp/lock.$$1" 2>/dev/null || return 0 | ||
| code=$$(curl -s -o "/tmp/out.$$1" -w '%{http_code}' --max-time 600 -H "Authorization: Bearer $$CRON_SECRET" "$$CAP_WEB_INTERNAL_URL/api/cron/$$1") | ||
| echo "$$(date -u +%FT%TZ) $$1 $$code $$(head -c 500 "/tmp/out.$$1")" | ||
| rmdir "/tmp/lock.$$1" | ||
| } | ||
| rmdir /tmp/lock.* 2>/dev/null | ||
| while :; do | ||
| jobs >/dev/null | ||
| touch /tmp/heartbeat | ||
| sleep $$((60 - $$(date +%s) % 60)) & | ||
| wait $$! | ||
| m=$$(date -u +%M); m=$${m#0} | ||
| h=$$(date -u +%H); h=$${h#0} | ||
| case $$m in 7|22|37|52) run recover-failed-video-processing & ;; esac | ||
| if [ $$((m % 15)) -eq 0 ]; then run finalize-stale-desktop-segments & fi | ||
| if [ "$$h" = 3 ] && [ "$$m" = 17 ]; then run cleanup-agent-api & fi | ||
| done | ||
| healthcheck: | ||
| test: ["CMD", "sh", "-c", "find /tmp/heartbeat -mmin -3 | grep -q ."] | ||
| interval: 60s | ||
| timeout: 5s | ||
| retries: 3 | ||
| start_period: 90s | ||
| networks: | ||
| - cap-network | ||
|
|
||
| mysql: | ||
| container_name: cap-mysql | ||
| image: mysql:8.0 | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The workflow invokes each endpoint directly with
docker exec, bypassing the new scheduler’s timing, route interpolation, and locking logic. A regression that leavescap-cronhealthy but prevents scheduled requests from launching would therefore still pass CI. Exercise at least one request through the scheduler path or make that scheduling logic independently testable.Prompt To Fix With AI