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
|
||||
|
||||
Reference in New Issue
Block a user