Spaces:
Sleeping
Sleeping
File size: 1,068 Bytes
4c83ab6 b96346f 0a367ef 4c83ab6 b96346f 7da71bc b96346f 4c83ab6 b96346f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | #!/bin/bash
set -e
# Apply DB migrations once (idempotent — both processes also call init_db
# defensively in case alembic was skipped during local dev).
alembic upgrade head
# Start the background routing processor (poll loop).
python -m app.processor &
PROCESSOR_PID=$!
# Start the standalone scheduler (subscription bootstrap + APScheduler cron
# jobs). Runs in its own process so the FastAPI server below can scale to
# multiple uvicorn workers without duplicating cron work.
python -m app.scheduler_main &
SCHEDULER_PID=$!
# Forward SIGTERM/SIGINT and EXIT to the background processes so the
# container shuts down cleanly.
trap "kill ${PROCESSOR_PID} ${SCHEDULER_PID} 2>/dev/null; \
wait ${PROCESSOR_PID} ${SCHEDULER_PID} 2>/dev/null" EXIT TERM INT
# FastAPI in the foreground. UVICORN_WORKERS controls horizontal scaling
# of the webhook receiver. Safe to bump because scheduler + processor are
# in their own processes.
exec uvicorn app.main:app \
--host "${HOST:-0.0.0.0}" \
--port "${PORT:-8000}" \
--workers "${UVICORN_WORKERS:-2}"
|