new options
This commit is contained in:
@@ -5,8 +5,8 @@ from utils.haproxy_config import update_haproxy_config, is_frontend_exist, count
|
||||
|
||||
main_bp = Blueprint('main', __name__)
|
||||
|
||||
|
||||
def reload_haproxy():
|
||||
"""Reload HAProxy via supervisorctl"""
|
||||
try:
|
||||
result = subprocess.run(
|
||||
['/usr/sbin/haproxy', '-f', '/etc/haproxy/haproxy.cfg', '-c'],
|
||||
@@ -17,25 +17,29 @@ def reload_haproxy():
|
||||
|
||||
if result.returncode != 0:
|
||||
print(f"[HAPROXY] Config validation failed: {result.stderr}", flush=True)
|
||||
return False, "Config validation failed"
|
||||
return False, f"Config validation failed: {result.stderr}"
|
||||
|
||||
print("[HAPROXY] Config valid, attempting restart via supervisorctl...", flush=True)
|
||||
|
||||
result = subprocess.run(
|
||||
['/usr/bin/supervisorctl', 'restart', 'haproxy'],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
timeout=10
|
||||
timeout=15
|
||||
)
|
||||
|
||||
if result.returncode == 0:
|
||||
print(f"[HAPROXY] Restarted successfully via supervisorctl", flush=True)
|
||||
return True, "HAProxy restarted successfully"
|
||||
else:
|
||||
print(f"[HAPROXY] Restart failed: {result.stderr}", flush=True)
|
||||
return False, f"Restart failed: {result.stderr}"
|
||||
stderr = result.stderr or result.stdout
|
||||
print(f"[HAPROXY] Restart failed: {stderr}", flush=True)
|
||||
return False, f"Restart failed: {stderr}"
|
||||
|
||||
except Exception as e:
|
||||
print(f"[HAPROXY] Error reloading: {e}", flush=True)
|
||||
return False, f"Error: {e}"
|
||||
print(f"[HAPROXY] Error: {e}", flush=True)
|
||||
return False, f"Error: {str(e)}"
|
||||
|
||||
|
||||
@main_bp.route('/', methods=['GET', 'POST'])
|
||||
@requires_auth
|
||||
|
||||
@@ -5,6 +5,16 @@ loglevel=info
|
||||
logfile=/var/log/supervisor/supervisord.log
|
||||
pidfile=/var/run/supervisord.pid
|
||||
|
||||
[unix_http_server]
|
||||
file=/var/run/supervisor.sock
|
||||
chmod=0700
|
||||
|
||||
[supervisorctl]
|
||||
serverurl=unix:///var/run/supervisor.sock
|
||||
|
||||
[rpcinterface:supervisor]
|
||||
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
|
||||
|
||||
[program:haproxy]
|
||||
command=/usr/sbin/haproxy -f /etc/haproxy/haproxy.cfg
|
||||
autostart=true
|
||||
@@ -28,10 +38,3 @@ priority=999
|
||||
environment=FLASK_APP=/app/app.py,FLASK_ENV=production,PYTHONUNBUFFERED=1
|
||||
startsecs=10
|
||||
stopasgroup=true
|
||||
|
||||
[unix_http_server]
|
||||
file=/var/run/supervisor.sock
|
||||
chmod=0700
|
||||
|
||||
[supervisorctl]
|
||||
serverurl=unix:///var/run/supervisor.sock
|
||||
|
||||
Reference in New Issue
Block a user