The previous check wasn't handling it already running.

Change-Id: I43ce52f64e907f832dd91a74a3834fee04194a32
This commit is contained in:
Joshua Harlow 2013-07-25 23:15:47 -07:00
parent e291382927
commit 0b4c0758e9
2 changed files with 19 additions and 6 deletions

View File

@ -79,11 +79,24 @@ class RabbitInstaller(binstall.PkgInstallComponent):
class RabbitRuntime(bruntime.ProgramRuntime):
def start(self):
if self.statii()[0].status != bruntime.STATUS_STARTED:
self._run_action('start')
def is_active():
status = self.statii()[0].status
if status == bruntime.STATUS_STARTED:
return True
return False
if is_active():
return 1
else:
raise RuntimeError('Failed to start rabbit-mq')
self._run_action('start')
for sleep_secs in utils.ExponentialBackoff():
LOG.info("Sleeping for %s seconds, rabbit-mq is still not active.",
sleep_secs)
sh.sleep(sleep_secs)
if is_active():
return 1
raise RuntimeError('Failed to start rabbit-mq')
@property
def applications(self):

View File

@ -93,7 +93,7 @@ LOG = logging.getLogger(__name__)
class ExponentialBackoff(object):
def __init__(self, start, attempts):
def __init__(self, attempts=5, start=1.3):
self.start = start
self.attempts = attempts
@ -168,7 +168,7 @@ def wait_for_url(url, max_attempts=5):
excps = []
attempts = 0
for sleep_time in ExponentialBackoff(1.3, max_attempts):
for sleep_time in ExponentialBackoff(attempts=max_attempts):
attempts += 1
try:
with contextlib.closing(urllib2.urlopen(urllib2.Request(url))) as req: