From 4aa8f2b7dac679dd440f7b5d5de4f58be06a9a14 Mon Sep 17 00:00:00 2001 From: Endre Karlson Date: Wed, 9 Oct 2013 11:36:31 +0200 Subject: [PATCH] [WORKER] Allow haproxy logfile path to be configurable Change-Id: Ia7569106226022b8901038bc2444fc5e1e9f91c1 --- doc/worker/config.rst | 4 ++++ etc/sample_libra.cfg | 1 + libra/tests/test_worker_controller.py | 2 +- libra/worker/drivers/haproxy/driver.py | 4 ++-- libra/worker/main.py | 9 ++++++++- 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/doc/worker/config.rst b/doc/worker/config.rst index ffc57144..db9acbf6 100644 --- a/doc/worker/config.rst +++ b/doc/worker/config.rst @@ -63,6 +63,10 @@ Command Line Options Full path to the file with the SSL private key to use when connecting to an SSL-enabled Gearman job server. + .. option:: --haproxy_logfile + + Configure the path for where to put haproxy log. + .. option:: -s , --reconnect_sleep The number of seconds to sleep between job server reconnect attempts diff --git a/etc/sample_libra.cfg b/etc/sample_libra.cfg index 1730d6b0..533fa164 100644 --- a/etc/sample_libra.cfg +++ b/etc/sample_libra.cfg @@ -32,6 +32,7 @@ gearman_poll = 60 server = 10.0.0.1:4730 10.0.0.2:4730 pid = /var/run/libra/libra_worker.pid logfile = /var/log/libra/libra_worker.log +haproxy_logfile = /var/log/haproxy.log # The [mgm] section is specific to the libra_mgm utility. diff --git a/libra/tests/test_worker_controller.py b/libra/tests/test_worker_controller.py index f79255e6..f958aaa4 100644 --- a/libra/tests/test_worker_controller.py +++ b/libra/tests/test_worker_controller.py @@ -16,7 +16,7 @@ class TestWorkerController(testtools.TestCase): self.logger.setLevel(logging.DEBUG) self.logger.addHandler(self.lh) self.driver = HAProxyDriver('libra.tests.mock_objects.FakeOSServices', - None, None) + None, None, None) def testBadAction(self): msg = { diff --git a/libra/worker/drivers/haproxy/driver.py b/libra/worker/drivers/haproxy/driver.py index 3444a0a7..1fccf574 100644 --- a/libra/worker/drivers/haproxy/driver.py +++ b/libra/worker/drivers/haproxy/driver.py @@ -26,8 +26,8 @@ from libra.worker.drivers.haproxy.services_base import ServicesBase class HAProxyDriver(LoadBalancerDriver): - def __init__(self, ossvc, user, group): - self.haproxy_log = '/mnt/log/haproxy.log' + def __init__(self, ossvc, user, group, haproxy_logfile=None): + self.haproxy_log = haproxy_logfile self.user = user self.group = group ossvc_driver = importutils.import_class(ossvc) diff --git a/libra/worker/main.py b/libra/worker/main.py index 782af548..f0f108fa 100644 --- a/libra/worker/main.py +++ b/libra/worker/main.py @@ -109,6 +109,11 @@ def main(): choices=haproxy_services.keys(), default='ubuntu', help='os services to use with HAProxy driver (when used)' ) + options.parser.add_argument( + '--haproxy_logfile', type=str, + default='/var/log/haproxy.log', + help="Where to store the HAProxy logfile" + ) options.parser.add_argument( '-s', '--reconnect_sleep', type=int, metavar='TIME', default=60, help='seconds to sleep between job server reconnects' @@ -126,6 +131,7 @@ def main(): '--gearman_poll', type=int, metavar='TIME', default=1, help='Gearman worker polling timeout' ) + args = options.run() if not args.server: @@ -157,7 +163,8 @@ def main(): group = None driver = driver_class(haproxy_services[args.haproxy_service], - user, group) + user, group, + haproxy_logfile=args.haproxy_logfile) else: driver = driver_class()