Files
contact.allucanget.biz/entrypoint.sh
zwitschi 4cefd4e3ab
Some checks failed
CI / test (3.11) (push) Failing after 5m36s
CI / build-image (push) Has been skipped
v1
2025-10-22 16:48:55 +02:00

29 lines
851 B
Bash

#!/bin/sh
set -e
# If GUNICORN_WORKERS is unset or set to the default placeholder, auto-calc based on CPU
if [ -z "${GUNICORN_WORKERS}" ] || [ "${GUNICORN_WORKERS}" = "2" ]; then
# Default formula: (2 x $CPU) + 1
CPU=$(getconf _NPROCESSORS_ONLN 2>/dev/null || echo 1)
GUNICORN_WORKERS=$((CPU * 2 + 1))
fi
if [ ${GUNICORN_WORKERS} -gt 8 ]; then
GUNICORN_WORKERS=8
fi
: ${GUNICORN_TIMEOUT:=30}
echo "Starting gunicorn with ${GUNICORN_WORKERS} workers and timeout ${GUNICORN_TIMEOUT}s"
# Determine WSGI module: prefer server.app if present, otherwise fall back to app
MODULE="app"
if [ -f "/app/server/app.py" ]; then
MODULE="server.app"
elif [ -f "/app/app.py" ]; then
MODULE="app"
fi
echo "Using WSGI module: ${MODULE}"
exec gunicorn ${MODULE}:app -b 0.0.0.0:5002 -w ${GUNICORN_WORKERS} --timeout ${GUNICORN_TIMEOUT} --log-level info