From 7550df9890328e0ab82ea91729f8240b6f1e4935 Mon Sep 17 00:00:00 2001 From: jknapp Date: Fri, 18 Apr 2025 16:52:57 -0700 Subject: [PATCH] Fixing reload issue --- haproxy_manager.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/haproxy_manager.py b/haproxy_manager.py index fc45805..b6c3e94 100644 --- a/haproxy_manager.py +++ b/haproxy_manager.py @@ -154,10 +154,13 @@ def regenerate_conf(): @app.route('/api/reload', methods=['GET']) def reload_haproxy(): if is_process_running('haproxy'): - result = subprocess.run(['echo', '"reload"', '|', 'socat', 'stdio', '/tmp/haproxy-cli'],check=True,capture_output=True, text=True, shell=True) - print(f"result.stdout, result.stderr, result.returncode") + # Use a proper shell command string when shell=True is set + result = subprocess.run('echo "reload" | socat stdio /tmp/haproxy-cli', + check=True, capture_output=True, text=True, shell=True) + print(f"Reload result: {result.stdout}, {result.stderr}, {result.returncode}") return jsonify({'status': 'success'}), 200 else: + # Start HAProxy if it's not running try: result = subprocess.run( ['haproxy', '-W', '-S', '/tmp/haproxy-cli,level,admin', '-f', HAPROXY_CONFIG_PATH], -- 2.43.5