[WORKER] Allow haproxy logfile path to be configurable

Change-Id: Ia7569106226022b8901038bc2444fc5e1e9f91c1
This commit is contained in:
Endre Karlson
2013-10-09 11:36:31 +02:00
parent 17a12bfc10
commit 4aa8f2b7da
5 changed files with 16 additions and 4 deletions

View File

@@ -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 <FILE>
Configure the path for where to put haproxy log.
.. option:: -s <SECONDS>, --reconnect_sleep <SECONDS>
The number of seconds to sleep between job server reconnect attempts

View File

@@ -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.

View File

@@ -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 = {

View File

@@ -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)

View File

@@ -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()