29 lines
748 B
Bash
29 lines
748 B
Bash
#!/bin/bash
|
|
# Production startup script for HabitForge
|
|
|
|
set -e
|
|
|
|
echo "Starting HabitForge in production mode..."
|
|
|
|
# Wait for database to be ready
|
|
echo "Waiting for database..."
|
|
while ! pg_isready -h ${POSTGRES_HOST:-db} -U ${POSTGRES_USER:-habitforge} -d ${POSTGRES_DB:-habitforge} > /dev/null 2>&1; do
|
|
echo "Database is unavailable - sleeping"
|
|
sleep 1
|
|
done
|
|
echo "Database is ready!"
|
|
|
|
# Run migrations
|
|
echo "Running database migrations..."
|
|
alembic upgrade head
|
|
|
|
# Start Gunicorn
|
|
echo "Starting Gunicorn..."
|
|
exec gunicorn backend.main:app \
|
|
--workers ${GUNICORN_WORKERS:-4} \
|
|
--worker-class uvicorn.workers.UvicornWorker \
|
|
--bind 0.0.0.0:8000 \
|
|
--access-logfile - \
|
|
--error-logfile - \
|
|
--log-level ${LOG_LEVEL:-info}
|