Files
leocrm/prestart.sh
T

25 lines
877 B
Bash
Raw Normal View History

2026-06-03 23:51:59 +00:00
#!/bin/sh
# =============================================================================
2026-07-25 21:03:46 +02:00
# prestart.sh — Container entrypoint for CRM API container
2026-06-03 23:51:59 +00:00
#
# Responsibilities:
# 1. Run Alembic DB migrations (alembic upgrade head).
2026-07-25 21:03:46 +02:00
# 2. Start uvicorn as PID 1 (so signals like SIGTERM are forwarded correctly).
2026-06-03 23:51:59 +00:00
#
# Notes:
# - `set -e` ensures the container crashes loudly if migrations fail.
2026-07-25 21:03:46 +02:00
# - The ARQ worker runs in a separate container (see worker.sh / docker-compose).
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."
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