The previous check wasn't handling it already running.
Change-Id: I43ce52f64e907f832dd91a74a3834fee04194a32
This commit is contained in:
parent
e291382927
commit
0b4c0758e9
@ -79,11 +79,24 @@ class RabbitInstaller(binstall.PkgInstallComponent):
|
|||||||
|
|
||||||
class RabbitRuntime(bruntime.ProgramRuntime):
|
class RabbitRuntime(bruntime.ProgramRuntime):
|
||||||
def start(self):
|
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
|
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
|
@property
|
||||||
def applications(self):
|
def applications(self):
|
||||||
|
@ -93,7 +93,7 @@ LOG = logging.getLogger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
class ExponentialBackoff(object):
|
class ExponentialBackoff(object):
|
||||||
def __init__(self, start, attempts):
|
def __init__(self, attempts=5, start=1.3):
|
||||||
self.start = start
|
self.start = start
|
||||||
self.attempts = attempts
|
self.attempts = attempts
|
||||||
|
|
||||||
@ -168,7 +168,7 @@ def wait_for_url(url, max_attempts=5):
|
|||||||
|
|
||||||
excps = []
|
excps = []
|
||||||
attempts = 0
|
attempts = 0
|
||||||
for sleep_time in ExponentialBackoff(1.3, max_attempts):
|
for sleep_time in ExponentialBackoff(attempts=max_attempts):
|
||||||
attempts += 1
|
attempts += 1
|
||||||
try:
|
try:
|
||||||
with contextlib.closing(urllib2.urlopen(urllib2.Request(url))) as req:
|
with contextlib.closing(urllib2.urlopen(urllib2.Request(url))) as req:
|
||||||
|
Loading…
Reference in New Issue
Block a user