This commit is contained in:
Joan
2025-11-27 16:27:01 +01:00
parent 33cc9586c2
commit 81f8912059
304 changed files with 56149 additions and 10122 deletions

View File

@@ -1,20 +1,14 @@
#!/bin/bash
# Startup script for API with auto-scaling workers
# Detect number of CPU cores
# Auto-detect worker count based on CPU cores
# Formula: (CPU_cores / 2) + 1, min 2, max 8
CPU_CORES=$(nproc)
WORKERS=$(( ($CPU_CORES / 2) + 1 ))
WORKERS=$(( WORKERS < 2 ? 2 : WORKERS ))
WORKERS=$(( WORKERS > 8 ? 8 : WORKERS ))
# 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)"
echo "Starting API with $WORKERS workers (auto-detected from $CPU_CORES CPU cores)"
exec gunicorn api.main:app \
--workers $WORKERS \