Skip to content

Commit

Permalink
Loop over outbound relay endpoints until we find one that works.
Browse files Browse the repository at this point in the history
  • Loading branch information
ralphbean committed Dec 10, 2012
1 parent dd706bc commit 8a3f19b
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions fedmsg/commands/relay.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

from kitchen.iterutils import iterate


class RelayCommand(BaseCommand):
""" Relay connections from active loggers to the bus.
Expand All @@ -43,11 +44,12 @@ class RelayCommand(BaseCommand):
name = 'fedmsg-relay'

def run(self):
# Do just like in fedmsg.commands.hub and mangle fedmsg-config.py to work
# Do just like in fedmsg.commands.hub and mangle fedmsg.d/ to work
# with moksha's expected configuration.
moksha_options = dict(
zmq_publish_endpoints=",".join(self.config['endpoints']["relay_outbound"]),
zmq_subscribe_endpoints=",".join(list(iterate(self.config['relay_inbound']))),
zmq_subscribe_endpoints=",".join(list(iterate(
self.config['relay_inbound']
))),
zmq_subscribe_method="bind",
)
self.config.update(moksha_options)
Expand All @@ -56,7 +58,15 @@ def run(self):
self.config[RelayConsumer.config_key] = True

from moksha.hub import main
main(options=self.config, consumers=[RelayConsumer])
for publish_endpoint in self.config['endpoints']['relay_outbound']:
self.config['zmq_publish_endpoints'] = publish_endpoint
try:
return main(options=self.config, consumers=[RelayConsumer])
except zmq.core.error.ZMQError:
self.log.debug("Failed to bind to %r" % publish_endpoint)

raise IOError("Failed to bind to any outbound endpoints.")


def relay():
command = RelayCommand()
Expand Down

0 comments on commit 8a3f19b

Please sign in to comment.