Skip to content

Commit

Permalink
pybing/mgr/prometheus: tidy up cherrypy engine start and stop
Browse files Browse the repository at this point in the history
Calling cherrypy.engine.block() in the stanby module results in a failing
mgr failover.

Signed-off-by: Jan Fajerski <jfajerski@suse.com>
(cherry picked from commit ff471d4)
  • Loading branch information
Jan Fajerski authored and b-ranto committed Apr 3, 2018
1 parent 0ed3fa0 commit c11732d
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/pybind/mgr/prometheus/module.py
Expand Up @@ -143,8 +143,6 @@ class Module(MgrModule):

def __init__(self, *args, **kwargs):
super(Module, self).__init__(*args, **kwargs)
self.notified = False
self.serving = False
self.metrics = self._setup_static_metrics()
self.schema = OrderedDict()
_global_instance['plugin'] = self
Expand Down Expand Up @@ -473,12 +471,16 @@ def metrics(self):
'engine.autoreload.on': False
})
cherrypy.tree.mount(Root(), "/")
self.log.info('Starting engine...')
cherrypy.engine.start()
self.log.info('Engine started.')
cherrypy.engine.block()

def shutdown(self):
self.serving = False
pass
self.log.info('Stopping engine...')
cherrypy.engine.wait(state=cherrypy.engine.states.STARTED)
cherrypy.engine.exit()
self.log.info('Stopped engine')


class StandbyModule(MgrStandbyModule):
Expand All @@ -492,7 +494,6 @@ def serve(self):
'engine.autoreload.on': False
})


module = self

class Root(object):
Expand All @@ -515,13 +516,14 @@ def metrics(self):
return ''

cherrypy.tree.mount(Root(), '/', {})
cherrypy.engine.wait(state=cherrypy.engine.states.STOPPED)
self.log.info('Starting engine...')
cherrypy.engine.start()
self.log.info("Waiting for engine...")
cherrypy.engine.wait(state=cherrypy.engine.states.STOPPED)
self.log.info('Engine started.')
cherrypy.engine.block()

def shutdown(self):
self.log.info('Stopping engine...')
self.log.info('Stopped engine')
pass
self.log.info("Stopping engine...")
cherrypy.engine.wait(state=cherrypy.engine.states.STARTED)
cherrypy.engine.stop()
self.log.info("Stopped engine")

0 comments on commit c11732d

Please sign in to comment.