0fe1674753
The image library is on a CIFS/SMB share (mounted rsize=4 MiB, actimeo=1), and Quart's FileBody streams in 8 KiB chunks — so serving one large original was ~19k network round-trips to the storage server, i.e. 30–58s per download (operator-flagged). That's what starved the GPU agent (constant "curator unreachable" backoff) AND slowed the browser: every byte is read off CIFS and streamed through the Python app (no reverse-proxy sendfile), and only 2 hypercorn workers meant the agent + the browser's thumbnail grid queued behind each other. In-container fix, no new service: - Raise FileBody.buffer_size 8 KiB → 4 MiB in create_app, matching the mount's read size: one round-trip per read, ~500× fewer. buffer_size is the MAX read so small thumbnails still read in one gulp, and Range/mime/ETag/conditional handling lives on Response — all preserved. Guarded so a Quart-internal change can't break boot. - HYPERCORN_WORKERS default 2 → 4 so concurrent /images requests stop queuing. Expected: large-file transfers drop from ~40s toward link speed (a few seconds) for the agent and the browser. See issue #1223. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ttrj5P7upUTueSfoJcxEqa
70 lines
2.1 KiB
Bash
Executable File
70 lines
2.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
ROLE="${1:-web}"
|
|
shift || true
|
|
|
|
case "$ROLE" in
|
|
web)
|
|
echo "[entrypoint] Running alembic upgrade head"
|
|
alembic upgrade head
|
|
echo "[entrypoint] Starting hypercorn on :8080"
|
|
# create_app is a factory — the `()` tells hypercorn to call it once
|
|
# and serve the returned Quart (ASGI) app, rather than treating the
|
|
# function itself as the application (which it then mis-invokes as WSGI).
|
|
# Default 4 workers (was 2): each worker is one asyncio loop, and a large
|
|
# file download occupies its worker for the transfer — 2 was too few once the
|
|
# GPU agent + the browser's thumbnail grid hit /images concurrently (they
|
|
# queued behind each other). Env-tunable via HYPERCORN_WORKERS.
|
|
exec hypercorn \
|
|
--bind 0.0.0.0:8080 \
|
|
--workers "${HYPERCORN_WORKERS:-4}" \
|
|
--access-logfile - \
|
|
"backend.app:create_app()"
|
|
;;
|
|
|
|
worker)
|
|
QUEUES="${CELERY_QUEUES:-default,import,thumbnail}"
|
|
CONCURRENCY="${CELERY_CONCURRENCY:-2}"
|
|
echo "[entrypoint] Starting Celery worker queues=$QUEUES concurrency=$CONCURRENCY"
|
|
exec celery -A backend.app.celery_app:celery worker \
|
|
--loglevel=info \
|
|
-Q "$QUEUES" \
|
|
--concurrency="$CONCURRENCY"
|
|
;;
|
|
|
|
scheduler)
|
|
QUEUES="${CELERY_QUEUES:-maintenance,scan}"
|
|
echo "[entrypoint] Starting Celery beat+worker queues=$QUEUES"
|
|
exec celery -A backend.app.celery_app:celery worker \
|
|
--beat \
|
|
--loglevel=info \
|
|
-Q "$QUEUES" \
|
|
--concurrency=1
|
|
;;
|
|
|
|
ml-worker)
|
|
echo "[entrypoint] Ensuring ML models present in /models..."
|
|
python -m backend.app.scripts.download_models
|
|
echo "[entrypoint] Starting ML Celery worker (ml queue)"
|
|
exec celery -A backend.app.celery_app:celery worker \
|
|
--loglevel=info \
|
|
-Q ml \
|
|
--concurrency=1
|
|
;;
|
|
|
|
shell|bash)
|
|
exec /bin/bash "$@"
|
|
;;
|
|
|
|
alembic)
|
|
exec alembic "$@"
|
|
;;
|
|
|
|
*)
|
|
echo "[entrypoint] Unknown role: $ROLE" >&2
|
|
echo "[entrypoint] Valid roles: web | worker | scheduler | ml-worker | shell | alembic" >&2
|
|
exit 1
|
|
;;
|
|
esac
|