File size: 1,032 Bytes
73c3776 11119e7 |
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 31 32 33 34 35 36 |
#!/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 |