From 33748733914968dafb279804fb7da16fd89c4fcb Mon Sep 17 00:00:00 2001 From: Daniel Pawlik Date: Fri, 3 Dec 2021 10:56:48 +0100 Subject: [PATCH] Parametrize Gearman client listening port and host The Log Gearman Client got hardcoded value for listening host and it also uses default Gear port (4730) for listening. It would be helpful for some deployments to parametrize those options. Change-Id: I01f41468f66008bf8ee7902e9f7dd4b31abbbf45 --- ansible/roles/loggearman/defaults/main.yml | 4 +++- ansible/roles/loggearman/templates/client.yml.j2 | 2 ++ loggearman/loggearman/client.py | 5 ++++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ansible/roles/loggearman/defaults/main.yml b/ansible/roles/loggearman/defaults/main.yml index 00cb888..cd53d66 100644 --- a/ansible/roles/loggearman/defaults/main.yml +++ b/ansible/roles/loggearman/defaults/main.yml @@ -10,6 +10,8 @@ container_images: loggearman: quay.rdoproject.org/software-factory/loggearman:latest # Gearman client +gearman_client_host: 0.0.0.0 +gearman_client_port: 4730 source_url: "" zmq_publishers: [] subunit_files: [] @@ -17,7 +19,7 @@ source_files: [] # Gearman worker gearman_host: 0.0.0.0 -gearman_port: 4731 +gearman_port: 4730 output_host: logstash.example.com output_port: 9999 output_mode: tcp diff --git a/ansible/roles/loggearman/templates/client.yml.j2 b/ansible/roles/loggearman/templates/client.yml.j2 index 359f350..df01c77 100644 --- a/ansible/roles/loggearman/templates/client.yml.j2 +++ b/ansible/roles/loggearman/templates/client.yml.j2 @@ -1,4 +1,6 @@ --- +gearman-host: {{ gearman_client_host }} +gearman-port: {{ gearman_client_port }} source-url: {{ source_url }} zmq-publishers: {{ zmq_publishers }} subunit-files: {{ subunit_files }} diff --git a/loggearman/loggearman/client.py b/loggearman/loggearman/client.py index 8eb0f5a..5dbff17 100755 --- a/loggearman/loggearman/client.py +++ b/loggearman/loggearman/client.py @@ -167,7 +167,9 @@ class Server(object): def setup_processors(self): for publisher in self.config['zmq-publishers']: gearclient = gear.Client() - gearclient.addServer('localhost') + host = self.config.get('gearman-host', 'localhost') + port = self.config.get('gearman-port', 4730) + gearclient.addServer(host, port=port) gearclient.waitForServer() log_processor = EventProcessor( publisher, gearclient, @@ -198,6 +200,7 @@ class Server(object): if statsd_host: self.wait_for_name_resolution(statsd_host, statsd_port) self.gearserver = gear.Server( + port=self.config.get('gearman-port', 4730), statsd_host=statsd_host, statsd_port=statsd_port, statsd_prefix=statsd_prefix)