Files

39 lines
1.1 KiB
Bash
Executable File

#!/usr/bin/env bash
# One-command local test startup for the EPUB->PDF converter.
# Foreground gunicorn with an auto-restart loop (no systemd/supervisor needed).
#
# ./start.sh # http://0.0.0.0:8030
# PORT=9000 ./start.sh # custom port
#
# WORKERS is pinned to 1: the job registry (app.JOBS) is in-memory per
# process, so multiple workers would lose job state between requests.
# Extra concurrency comes from --threads instead. The gunicorn flags mirror
# the Dockerfile CMD (single source of truth for the launch contract).
set -u
cd "$(dirname "$0")"
HOST="${HOST:-0.0.0.0}"
PORT="${PORT:-8030}"
THREADS="${THREADS:-8}"
export DATA_DIR="${DATA_DIR:-$PWD/data}"
PY="${PY:-/opt/venv/bin/python}"
echo "[start] EPUB->PDF converter on http://${HOST}:${PORT}"
echo "[start] DATA_DIR=${DATA_DIR} workers=1 threads=${THREADS}"
while true; do
"$PY" -m gunicorn \
--bind "${HOST}:${PORT}" \
--workers 1 \
--threads "$THREADS" \
--timeout 1200 \
--graceful-timeout 30 \
--access-logfile - \
--error-logfile - \
app:app
code=$?
echo "[start] gunicorn exited (code ${code}); restarting in 2s..."
sleep 2
done