From 089d4434d9475478223fdf344f80944d8e40940d Mon Sep 17 00:00:00 2001 From: Joao Gilberto Magalhaes Date: Sun, 12 Feb 2023 20:08:12 -0600 Subject: [PATCH] Adjustment in the HAProxy conf.d --- src/functions/__init__.py | 4 +++- src/tests/test_daemonize.py | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/functions/__init__.py b/src/functions/__init__.py index 7f0a331..f4b9b3c 100644 --- a/src/functions/__init__.py +++ b/src/functions/__init__.py @@ -121,7 +121,9 @@ class DaemonizeHAProxy: self.thread.start() def get_haproxy_command(self, action): - custom_config_files = " ".join(["-f %s" % (file) for file in self.get_custom_config_files()]) + custom_config_files = "" + if len(list(self.get_custom_config_files().keys())) != 0: + custom_config_files = "-f %s" % (self.custom_config_folder) if action == "start": return "/usr/sbin/haproxy -W -f /etc/haproxy/haproxy.cfg %s -p /run/haproxy.pid -S /var/run/haproxy.sock" % (custom_config_files) diff --git a/src/tests/test_daemonize.py b/src/tests/test_daemonize.py index 5b8baa3..fb1ea08 100644 --- a/src/tests/test_daemonize.py +++ b/src/tests/test_daemonize.py @@ -36,9 +36,9 @@ def test_daemonize_haproxy_check_config(): def test_daemonize_haproxy_get_haproxy_command_start(): daemon = DaemonizeHAProxy(os.path.abspath(os.path.dirname(__file__)) + '/fixtures') command = daemon.get_haproxy_command("start") - assert command == "/usr/sbin/haproxy -W -f /etc/haproxy/haproxy.cfg -f %s/00_haproxy.cfg -f %s/10_haproxy.cfg -p /run/haproxy.pid -S /var/run/haproxy.sock" % (os.path.dirname(__file__) + "/fixtures", os.path.dirname(__file__) + "/fixtures") + assert command == "/usr/sbin/haproxy -W -f /etc/haproxy/haproxy.cfg -f %s -p /run/haproxy.pid -S /var/run/haproxy.sock" % (os.path.dirname(__file__) + "/fixtures") def test_daemonize_haproxy_get_haproxy_command_reload(): daemon = DaemonizeHAProxy(os.path.abspath(os.path.dirname(__file__)) + '/fixtures') command = daemon.get_haproxy_command("reload") - assert command == "/usr/sbin/haproxy -W -f /etc/haproxy/haproxy.cfg -f %s/00_haproxy.cfg -f %s/10_haproxy.cfg -p /run/haproxy.pid -x /var/run/haproxy.sock -sf " % (os.path.dirname(__file__) + "/fixtures", os.path.dirname(__file__) + "/fixtures") + assert command == "/usr/sbin/haproxy -W -f /etc/haproxy/haproxy.cfg -f %s -p /run/haproxy.pid -x /var/run/haproxy.sock -sf " % (os.path.dirname(__file__) + "/fixtures")