def main(period=None):
"""Constantly check services availability.
This runs infinite availability check with given period.
:param period: period in seconds
"""
if not config.get_config().get("regions"):
LOG.error("No regions configured. Quitting.")
return 1
period = period or config.get_config().get("period", 60)
if SERVICE_CONN_TIMEOUT + SERVICE_READ_TIMEOUT > period:
LOG.error("Period can not be lesser than timeout, "
"otherwise threads could crowd round.")
return 1
backend = config.get_config().get("backend")
if backend["type"] != "elastic":
LOG.error("Unexpected backend: %(type)s" % backend)
return 1
if not storage.get_elasticsearch(check_availability=True):
LOG.error("Failed to set up Elasticsearch")
return 1
LOG.info("Start watching with period %s seconds" % period)
schedule.every(period).seconds.do(watch_services)
while True:
time.sleep(1)
schedule.run_pending()
评论列表
文章目录