2026-06-03 23:51:59 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
# =============================================================================
|
|
|
|
|
# prestart.sh — Container entrypoint for CRM System
|
|
|
|
|
#
|
|
|
|
|
# Responsibilities:
|
|
|
|
|
# 1. Run Alembic DB migrations (alembic upgrade head).
|
2026-07-19 19:36:48 +02:00
|
|
|
# 2. Start ARQ background worker in background.
|
|
|
|
|
# 3. Start uvicorn as PID 1 (so signals like SIGTERM are forwarded correctly).
|
2026-06-03 23:51:59 +00:00
|
|
|
#
|
|
|
|
|
# Notes:
|
2026-07-19 19:36:48 +02:00
|
|
|
# - `set -e` ensures the container crashes loudly if migrations fail.
|
|
|
|
|
# - ARQ worker runs in background, uvicorn becomes PID 1.
|
|
|
|
|
# - `--workers 1` is intentional for v1.
|
2026-06-03 23:51:59 +00:00
|
|
|
# =============================================================================
|
|
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
|
|
echo "[prestart] $(date -u +%Y-%m-%dT%H:%M:%SZ) - Running alembic upgrade head..."
|
|
|
|
|
alembic upgrade head
|
|
|
|
|
echo "[prestart] DB migrations completed successfully."
|
|
|
|
|
|
2026-07-19 19:36:48 +02:00
|
|
|
echo "[prestart] Starting ARQ background worker..."
|
|
|
|
|
arq app.core.worker.WorkerSettings &
|
|
|
|
|
|
2026-06-03 23:51:59 +00:00
|
|
|
echo "[prestart] Starting uvicorn on 0.0.0.0:8000 (workers=1)..."
|
|
|
|
|
exec uvicorn app.main:app \
|
|
|
|
|
--host 0.0.0.0 \
|
|
|
|
|
--port 8000 \
|
|
|
|
|
--workers 1
|