def _wrapper(): try: log.setup('canary') func() except KeyboardInterrupt: LOG.info(u'Terminating') except Exception as ex: _fail(1, ex)
import functools import sys from oslo.config import cfg from canary.openstack.common import log from canary.transport.wsgi.driver import Driver app_container = Driver() conf = cfg.CONF conf(project='canary', prog='canary', args=[]) log.setup('canary') LOG = log.getLogger(__name__) def _fail(returncode, ex): """Handles terminal errors. :param returncode: process return code to pass to sys.exit :param ex: the error that occurred """ LOG.exception(ex) sys.exit(returncode)
from oslo.config import cfg from canary.common import cli from canary.openstack.common import log as logging from canary.transport.wsgi.driver import Driver conf = cfg.CONF conf(project='canary', prog='canary', args=[]) logging.setup('canary') LOG = logging.getLogger(__name__) @cli.runnable def run(): app_container = Driver() app_container.listen()
import importlib import json from oslo_config import cfg from taskflow.patterns import linear_flow from taskflow import task from canary.openstack.common import log from canary.model import JobBoard log.setup('canary') LOG = log.getLogger(__name__) def memoize(f): memo = {} def helper(*args, **kwargs): x = str(args) + str(kwargs) if x not in memo: memo[x] = f(*args, **kwargs) return memo[x] return helper @memoize def load_database_driver(): conf = cfg.CONF conf(project='canary', prog='canary', args=[])
from oslo_config import cfg from canary.openstack.common import log as logging from canary.tasks.taskflow import ServicesDriver conf = cfg.CONF conf(project="canary", prog="canary", args=[]) logging.setup("canary") LOG = logging.getLogger(__name__) def run(): LOG.info("Starting Canary Conductor") ServicesDriver().run_task_worker()