dedde400e1
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
36 lines
971 B
Bash
36 lines
971 B
Bash
#!/bin/sh
|
||
set -e
|
||
|
||
RETRY_INTERVAL=3
|
||
|
||
# If no db_config.json exists yet, skip the wait (first-run setup mode).
|
||
python - <<'EOF'
|
||
import sys, os
|
||
config_path = os.environ.get("DB_CONFIG_PATH", "/config/db_config.json")
|
||
if not os.path.exists(config_path):
|
||
sys.exit(1)
|
||
EOF
|
||
DB_CONFIGURED=$?
|
||
|
||
if [ "$DB_CONFIGURED" -eq 1 ]; then
|
||
echo "[entrypoint] Keine DB-Konfiguration gefunden – starte im Setup-Modus."
|
||
else
|
||
echo "[entrypoint] DB-Konfiguration gefunden – warte auf MariaDB..."
|
||
while true; do
|
||
python - <<'EOF'
|
||
import sys
|
||
from util.db_config import load_config, test_connection
|
||
config = load_config()
|
||
sys.exit(0 if config and test_connection(config) else 1)
|
||
EOF
|
||
if [ $? -eq 0 ]; then
|
||
echo "[entrypoint] MariaDB erreichbar – starte Flask."
|
||
break
|
||
fi
|
||
echo "[entrypoint] MariaDB noch nicht bereit – neuer Versuch in ${RETRY_INTERVAL}s..."
|
||
sleep "$RETRY_INTERVAL"
|
||
done
|
||
fi
|
||
|
||
exec python app.py
|