From 54dcb5309a248aa1455697167fe53fc724e0c2c1 Mon Sep 17 00:00:00 2001 From: Tristan Cacqueray Date: Wed, 7 Dec 2016 04:38:25 +0000 Subject: [PATCH] Increase rabbitmq connections attempt Workers instantly exit if rabbitmq server is not available. This changes use connection_attemps and retry_delay pika connection parameters to try to reconnect before failing. Change-Id: I00ff950270360405da092803c1d251552c837831 --- etc/storyboard.conf.sample | 6 ++++++ storyboard/notifications/conf.py | 4 ++++ storyboard/notifications/connection_service.py | 4 +++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/etc/storyboard.conf.sample b/etc/storyboard.conf.sample index 98cc8082..df30bfcc 100644 --- a/etc/storyboard.conf.sample +++ b/etc/storyboard.conf.sample @@ -107,6 +107,12 @@ lock_path = $state_path/lock # The name of the queue that will be created for API events. # rabbit_event_queue_name=storyboard_events +# The number of connection attempts before giving-up +# rabbit_connection_attempts = 6 + +# The interval between connection attempts (in seconds) +# rabbit_retry_delay = 10 + [database] # This line MUST be changed to actually run storyboard # Example: diff --git a/storyboard/notifications/conf.py b/storyboard/notifications/conf.py index 393f357e..325be8e1 100644 --- a/storyboard/notifications/conf.py +++ b/storyboard/notifications/conf.py @@ -40,4 +40,8 @@ NOTIFICATION_OPTS = [ cfg.StrOpt("rabbit_virtual_host", default="/", help="The virtual host within which our queues and exchanges " "live."), + cfg.IntOpt("rabbit_connection_attempts", default=6, + help="The number of connection attempts before giving-up"), + cfg.IntOpt("rabbit_retry_delay", default=10, + help="The interval between connection attempts (in seconds)") ] diff --git a/storyboard/notifications/connection_service.py b/storyboard/notifications/connection_service.py index d84a55e3..90efeea1 100644 --- a/storyboard/notifications/connection_service.py +++ b/storyboard/notifications/connection_service.py @@ -56,7 +56,9 @@ class ConnectionService(object): conf.rabbit_host, conf.rabbit_port, conf.rabbit_virtual_host, - self._connection_credentials) + self._connection_credentials, + connection_attempts=conf.rabbit_connection_attempts, + retry_delay=conf.rabbit_retry_delay) def _connect(self): """This method connects to RabbitMQ, establishes a channel, declares