File size: 635 Bytes
410e48e b005e33 410e48e ced4437 410e48e 20d5ed3 e319a61 20d5ed3 410e48e dc8b958 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | #!/bin/bash
# Limit PyTorch background threads so Gunicorn isn't starved
export OMP_NUM_THREADS=1
export MKL_NUM_THREADS=1
# Start Celery worker in background
# We use concurrency=2 to avoid memory overload on the 16GB free tier
celery -A tasks worker --loglevel=info --concurrency=2 -O fair -B &
CELERY_PID=$!
# Trap SIGTERM and SIGINT for graceful shutdown
trap "kill $CELERY_PID; exit 0" SIGTERM SIGINT
# Run database migrations/initialization
flask --app app_new init-db
# Start Gunicorn in foreground
# Hugging Face Spaces expects the app to listen on port 7860
gunicorn -w 4 -b 0.0.0.0:${PORT:-7860} --timeout 300 app_new:app
|