"feat: Added debug server and related components for improved development experience"
This commit is contained in:
56
backend/start-production.sh
Normal file
56
backend/start-production.sh
Normal file
@@ -0,0 +1,56 @@
|
||||
#!/bin/bash
|
||||
|
||||
# MYP Backend - Produktions-Startskript
|
||||
# Startet die Flask-Anwendung mit Gunicorn für den Produktionsbetrieb
|
||||
|
||||
set -e
|
||||
|
||||
echo "=== MYP Backend - Produktionsstart ==="
|
||||
|
||||
# Konfiguration
|
||||
WORKERS=${WORKERS:-4}
|
||||
BIND_ADDRESS=${BIND_ADDRESS:-"0.0.0.0:5000"}
|
||||
TIMEOUT=${TIMEOUT:-30}
|
||||
KEEP_ALIVE=${KEEP_ALIVE:-5}
|
||||
MAX_REQUESTS=${MAX_REQUESTS:-1000}
|
||||
MAX_REQUESTS_JITTER=${MAX_REQUESTS_JITTER:-100}
|
||||
|
||||
# Umgebungsvariablen
|
||||
export FLASK_ENV=production
|
||||
export PYTHONPATH=${PYTHONPATH}:$(pwd)
|
||||
|
||||
# Log-Verzeichnis erstellen
|
||||
mkdir -p logs
|
||||
|
||||
# Prüfe, ob alle erforderlichen Umgebungsvariablen gesetzt sind
|
||||
if [ -z "$SECRET_KEY" ]; then
|
||||
echo "WARNUNG: SECRET_KEY ist nicht gesetzt. Verwende einen generierten Schlüssel."
|
||||
export SECRET_KEY=$(python3 -c "import secrets; print(secrets.token_hex(32))")
|
||||
fi
|
||||
|
||||
# Produktionsparameter ausgeben
|
||||
echo "Konfiguration:"
|
||||
echo " - Workers: $WORKERS"
|
||||
echo " - Bind: $BIND_ADDRESS"
|
||||
echo " - Timeout: $TIMEOUT Sekunden"
|
||||
echo " - Max Requests: $MAX_REQUESTS"
|
||||
echo " - Environment: $FLASK_ENV"
|
||||
echo ""
|
||||
|
||||
# Gunicorn starten
|
||||
echo "Starte Gunicorn-Server..."
|
||||
exec gunicorn \
|
||||
--workers=$WORKERS \
|
||||
--worker-class=sync \
|
||||
--bind=$BIND_ADDRESS \
|
||||
--timeout=$TIMEOUT \
|
||||
--keep-alive=$KEEP_ALIVE \
|
||||
--max-requests=$MAX_REQUESTS \
|
||||
--max-requests-jitter=$MAX_REQUESTS_JITTER \
|
||||
--preload \
|
||||
--access-logfile=logs/access.log \
|
||||
--error-logfile=logs/error.log \
|
||||
--log-level=info \
|
||||
--capture-output \
|
||||
--enable-stdio-inheritance \
|
||||
wsgi:application
|
Reference in New Issue
Block a user