What a mess

This commit is contained in:
Joan
2025-11-07 15:27:13 +01:00
parent 0b79b3ae59
commit 33cc9586c2
130 changed files with 29819 additions and 1175 deletions

28
api/start.sh Normal file
View File

@@ -0,0 +1,28 @@
#!/bin/bash
# Startup script for API with auto-scaling workers
# Detect number of CPU cores
CPU_CORES=$(nproc)
# Calculate optimal workers: (2 x CPU cores) + 1
# But cap at 8 workers to avoid over-saturation
WORKERS=$((2 * CPU_CORES + 1))
if [ $WORKERS -gt 8 ]; then
WORKERS=8
fi
# Use environment variable if set, otherwise use calculated value
WORKERS=${API_WORKERS:-$WORKERS}
echo "Starting API with $WORKERS workers (detected $CPU_CORES CPU cores)"
exec gunicorn api.main:app \
--workers $WORKERS \
--worker-class uvicorn.workers.UvicornWorker \
--bind 0.0.0.0:8000 \
--timeout 120 \
--max-requests 1000 \
--max-requests-jitter 100 \
--access-logfile - \
--error-logfile - \
--log-level info