Run the periodic commands in a scheduler service (no host cron)

Adds deploy/scheduler-entrypoint.sh to the backend image (entrypoint
j621-scheduler) and a scheduler service to the four composes that have a
backend. It waits until the database and migrations are ready, runs every
job once, then keeps to the intervals:

  sync_followed_tags + sync_followed_pools   every 30 min (J621_SYNC_EVERY)
  cleanup_similarity                         hourly      (J621_CLEAN_EVERY)
  refresh_guest_blacklist                    daily       (J621_BLACKLIST_EVERY)

It shares the backend image, media volume and env file, so commands see
the same library and database; failures are logged and retried next
interval. Output goes to docker compose logs scheduler; the frontend-only
composes have no backend and therefore no scheduler.

Verified against a real stack: the scheduler waited for migrations, ran all
four commands on start (follow syncs as anonymous, similarity cleanup, and
a guest blacklist refresh that pulled the real 14-tag list from e621), and
kept looping. All six composes still validate.
This commit is contained in:
2026-09-18 12:51:17 -05:00
parent 93cce6b9fd
commit f25526782c
10 changed files with 204 additions and 5 deletions
+27
View File
@@ -66,6 +66,33 @@ services:
redis:
condition: service_healthy
# Periodic maintenance inside the deployment (no host cron): follow syncs,
# similarity cleanup and the guest blacklist refresh.
scheduler:
image: ${J621_REGISTRY:-gitea.rainbow-herring.ts.net/jakebreath}/j621-backend:${J621_TAG:-latest}
build:
context: ..
dockerfile: deploy/J621-Backend
args:
GIT_HASH: ${GIT_HASH:-unknown}
restart: unless-stopped
entrypoint: ["j621-scheduler"]
env_file: [./.env]
environment:
DB_HOST: mariadb
DB_PORT: "3306"
REDIS_URL: redis://redis:6379/1
SYNC_EVERY: ${J621_SYNC_EVERY:-1800}
CLEAN_EVERY: ${J621_CLEAN_EVERY:-3600}
BLACKLIST_EVERY: ${J621_BLACKLIST_EVERY:-86400}
volumes:
- ./data/media:/app/media
depends_on:
mariadb:
condition: service_healthy
redis:
condition: service_healthy
frontend:
image: ${J621_REGISTRY:-gitea.rainbow-herring.ts.net/jakebreath}/j621-frontend:${J621_TAG:-latest}
build: