Merge pull request 'Fixing reload issue' (#1) from fix-reload into main
All checks were successful
HAProxy Manager Build and Push / Build-and-Push (push) Successful in 38s

Reviewed-on: #1
This commit is contained in:
jknapp 2025-04-18 23:53:17 +00:00
commit 71b8085fb4

View File

@ -154,10 +154,13 @@ def regenerate_conf():
@app.route('/api/reload', methods=['GET']) @app.route('/api/reload', methods=['GET'])
def reload_haproxy(): def reload_haproxy():
if is_process_running('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) # Use a proper shell command string when shell=True is set
print(f"result.stdout, result.stderr, result.returncode") 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 return jsonify({'status': 'success'}), 200
else: else:
# Start HAProxy if it's not running
try: try:
result = subprocess.run( result = subprocess.run(
['haproxy', '-W', '-S', '/tmp/haproxy-cli,level,admin', '-f', HAPROXY_CONFIG_PATH], ['haproxy', '-W', '-S', '/tmp/haproxy-cli,level,admin', '-f', HAPROXY_CONFIG_PATH],