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
This commit is contained in:
Daniel Pawlik 2021-12-03 10:56:48 +01:00
parent dae8dcc0b1
commit 3374873391
3 changed files with 9 additions and 2 deletions

View File

@ -10,6 +10,8 @@ container_images:
loggearman: quay.rdoproject.org/software-factory/loggearman:latest loggearman: quay.rdoproject.org/software-factory/loggearman:latest
# Gearman client # Gearman client
gearman_client_host: 0.0.0.0
gearman_client_port: 4730
source_url: "" source_url: ""
zmq_publishers: [] zmq_publishers: []
subunit_files: [] subunit_files: []
@ -17,7 +19,7 @@ source_files: []
# Gearman worker # Gearman worker
gearman_host: 0.0.0.0 gearman_host: 0.0.0.0
gearman_port: 4731 gearman_port: 4730
output_host: logstash.example.com output_host: logstash.example.com
output_port: 9999 output_port: 9999
output_mode: tcp output_mode: tcp

View File

@ -1,4 +1,6 @@
--- ---
gearman-host: {{ gearman_client_host }}
gearman-port: {{ gearman_client_port }}
source-url: {{ source_url }} source-url: {{ source_url }}
zmq-publishers: {{ zmq_publishers }} zmq-publishers: {{ zmq_publishers }}
subunit-files: {{ subunit_files }} subunit-files: {{ subunit_files }}

View File

@ -167,7 +167,9 @@ class Server(object):
def setup_processors(self): def setup_processors(self):
for publisher in self.config['zmq-publishers']: for publisher in self.config['zmq-publishers']:
gearclient = gear.Client() 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() gearclient.waitForServer()
log_processor = EventProcessor( log_processor = EventProcessor(
publisher, gearclient, publisher, gearclient,
@ -198,6 +200,7 @@ class Server(object):
if statsd_host: if statsd_host:
self.wait_for_name_resolution(statsd_host, statsd_port) self.wait_for_name_resolution(statsd_host, statsd_port)
self.gearserver = gear.Server( self.gearserver = gear.Server(
port=self.config.get('gearman-port', 4730),
statsd_host=statsd_host, statsd_host=statsd_host,
statsd_port=statsd_port, statsd_port=statsd_port,
statsd_prefix=statsd_prefix) statsd_prefix=statsd_prefix)