Files
haproxy-dashboard/entrypoint.sh
Mateusz Gruszczyński addb21bc3e rewrite
2025-11-04 09:56:37 +01:00

42 lines
1.4 KiB
Bash

#!/bin/bash
set -e
echo "╔════════════════════════════════════════╗"
echo "║ HAProxy Manager - Entrypoint ║"
echo "║ Starting services... ║"
echo "╚════════════════════════════════════════╝"
# ===== CHECK ENVIRONMENT =====
echo "[STARTUP] Environment: ${FLASK_ENV:-production}"
echo "[STARTUP] Python version: $(python --version)"
# ===== INIT DATABASE =====
echo "[STARTUP] Initializing database..."
python -c "
from app import app
from database import init_db
with app.app_context():
init_db(app)
print('[STARTUP] Database initialized successfully')
" || {
echo "[ERROR] Database initialization failed!"
exit 1
}
# ===== GENERATE INITIAL HAPROXY CONFIG =====
echo "[STARTUP] Generating initial HAProxy config..."
python -c "
from app import app
from utils.config_generator import generate_haproxy_config, save_haproxy_config
with app.app_context():
config = generate_haproxy_config()
save_haproxy_config(config)
print('[STARTUP] HAProxy config generated')
" || {
echo "[WARNING] Could not generate initial config, continuing..."
}
# ===== START SUPERVISOR (runs Flask + HAProxy + other services) =====
echo "[STARTUP] Starting supervisord..."
exec /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf