v1
This commit is contained in:
28
entrypoint.sh
Normal file
28
entrypoint.sh
Normal file
@@ -0,0 +1,28 @@
|
||||
#!/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
|
||||
Reference in New Issue
Block a user