fb / start.sh
rastof9's picture
update
11119e7
Raw History Blame Contribute Delete
1.03 kB
#!/bin/bash
# start.sh - Application startup script
set -e # Exit immediately if a command exits with a non-zero status
echo "===== Starting Application at $(date -u '+%Y-%m-%d %H:%M:%S') ====="
# Run prestart script to check dependencies
if [ -f /app/prestart.sh ]; then
echo "Running prestart script..."
/app/prestart.sh
if [ $? -ne 0 ]; then
echo "Error: Prestart script failed. Exiting."
exit 1
fi
else
echo "Warning: Prestart script not found."
fi
# Check if gunicorn is installed
if ! command -v gunicorn &> /dev/null; then
echo "Error: gunicorn is not installed. Installing..."
pip install --no-cache-dir gunicorn
fi
# Check if gunicorn config exists
if [ ! -f ./gunicorn.conf.py ]; then
echo "Warning: gunicorn.conf.py not found. Using default configuration."
GUNICORN_OPTS="--workers=2 --bind=0.0.0.0:5000"
else
GUNICORN_OPTS="--config=./gunicorn.conf.py --workers=2"
fi
# Start gunicorn
echo "Starting gunicorn..."
exec gunicorn $GUNICORN_OPTS app:create_app