def main(): CONF.register_cli_opt(command_opt) try: logging.register_options(CONF) cfg_files = cfg.find_config_files(project='daisy', prog='daisy-registry') cfg_files.extend(cfg.find_config_files(project='daisy', prog='daisy-api')) cfg_files.extend(cfg.find_config_files(project='daisy', prog='daisy-manage')) cfg_files.extend(cfg.find_config_files(project='daisy', prog='daisy-orchestration')) config.parse_args(default_config_files=cfg_files, usage="%(prog)s [options] <cmd>") logging.setup(CONF, 'daisy') except RuntimeError as e: sys.exit("ERROR: %s" % e) try: if CONF.command.action.startswith('db'): return CONF.command.action_fn() else: func_kwargs = {} for k in CONF.command.action_kwargs: v = getattr(CONF.command, 'action_kwarg_' + k) if v is None: continue if isinstance(v, six.string_types): v = encodeutils.safe_decode(v) func_kwargs[k] = v func_args = [encodeutils.safe_decode(arg) for arg in CONF.command.action_args] return CONF.command.action_fn(*func_args, **func_kwargs) except exception.DaisyException as e: sys.exit("ERROR: %s" % utils.exception_to_str(e))
def main(): """The main function.""" try: config.parse_args() except RuntimeError as e: sys.exit("ERROR: %s" % utils.exception_to_str(e)) # Setup logging logging.setup('glance') if CONF.token: CONF.slavetoken = CONF.token CONF.mastertoken = CONF.token command = lookup_command(CONF.command) try: command(CONF, CONF.args) except TypeError as e: LOG.error(_LE(command.__doc__) % {'prog': command.__name__}) # noqa sys.exit("ERROR: %s" % utils.exception_to_str(e)) except ValueError as e: LOG.error(_LE(command.__doc__) % {'prog': command.__name__}) # noqa sys.exit("ERROR: %s" % utils.exception_to_str(e))
def main(): CONF.register_cli_opts(scrubber.scrubber_cmd_cli_opts) CONF.register_opts(scrubber.scrubber_cmd_opts) try: config.parse_args() logging.setup(CONF, 'glance') glance_store.register_opts(config.CONF) glance_store.create_stores(config.CONF) glance_store.verify_default_store() app = scrubber.Scrubber(glance_store) if CONF.daemon: server = scrubber.Daemon(CONF.wakeup_time) server.start(app) systemd.notify_once() server.wait() else: import eventlet pool = eventlet.greenpool.GreenPool(1000) app.run(pool) except RuntimeError as e: sys.exit("ERROR: %s" % e)
def main(): try: config.parse_args() logging.setup(CONF, 'daisy') timer = loopingcall.FixedIntervalLoopingCall( AutoBackupManager.auto_backup) timer.start(float(CONF.auto_backup.auto_backup_interval)).wait() except exception.WorkerCreationFailure as e: fail(2, e) except RuntimeError as e: fail(1, e)
def main(): try: config.parse_args() logging.setup(CONF, 'daisy') backend = get_backend() manager = "daisy.orchestration.%s.install" % backend api = importutils.import_module(manager) timer = loopingcall.FixedIntervalLoopingCall( api.find_auto_scale_cluster) timer.start(float(CONF.orchestration.auto_scale_interval)).wait() except exception.WorkerCreationFailure as e: fail(2, e) except RuntimeError as e: fail(1, e)
def main(): CONF.register_cli_opt(command_opt) try: logging.register_options(CONF) cfg_files = cfg.find_config_files(project='daisy', prog='daisy-registry') cfg_files.extend( cfg.find_config_files(project='daisy', prog='daisy-api')) cfg_files.extend( cfg.find_config_files(project='daisy', prog='daisy-manage')) cfg_files.extend( cfg.find_config_files(project='daisy', prog='daisy-orchestration')) cfg_files.extend( cfg.find_config_files(project='daisy', prog='daisy-auto-backup')) config.parse_args(default_config_files=cfg_files, usage="%(prog)s [options] <cmd>") logging.setup(CONF, 'daisy') except RuntimeError as e: sys.exit("ERROR: %s" % e) try: if CONF.command.action.startswith('db'): return CONF.command.action_fn() else: func_kwargs = {} for k in CONF.command.action_kwargs: v = getattr(CONF.command, 'action_kwarg_' + k) if v is None: continue if isinstance(v, six.string_types): v = encodeutils.safe_decode(v) func_kwargs[k] = v func_args = [ encodeutils.safe_decode(arg) for arg in CONF.command.action_args ] return CONF.command.action_fn(*func_args, **func_kwargs) except exception.DaisyException as e: sys.exit("ERROR: %s" % utils.exception_to_str(e))
def main(): try: config.parse_args() wsgi.set_eventlet_hub() logging.setup(CONF, 'daisy') if cfg.CONF.profiler.enabled: _notifier = osprofiler.notifier.create("Messaging", notifier.messaging, {}, notifier.get_transport(), "daisy", "api", cfg.CONF.bind_host) osprofiler.notifier.set(_notifier) else: osprofiler.web.disable() server = wsgi.Server() server.start(config.load_paste_app('daisy-api'), default_port=9292) systemd.notify_once() server.wait() except Exception as e: fail(e)
def main(): try: logging.register_options(CONF) cfg_files = cfg.find_config_files(project='glance', prog='glance-api') cfg_files.extend(cfg.find_config_files(project='glance', prog='glance-search')) config.parse_args(default_config_files=cfg_files) logging.setup(CONF, 'glance') namespace = 'daisy.search.index_backend' ext_manager = stevedore.extension.ExtensionManager( namespace, invoke_on_load=True) for ext in ext_manager.extensions: try: ext.obj.setup() except Exception as e: LOG.error(_LE("Failed to setup index extension " "%(ext)s: %(e)s") % {'ext': ext.name, 'e': e}) except RuntimeError as e: sys.exit("ERROR: %s" % e)
def main(): try: config.parse_args() wsgi.set_eventlet_hub() logging.setup(CONF, 'glance') if cfg.CONF.profiler.enabled: _notifier = osprofiler.notifier.create("Messaging", notifier.messaging, {}, notifier.get_transport(), "glance", "search", cfg.CONF.bind_host) osprofiler.notifier.set(_notifier) else: osprofiler.web.disable() server = wsgi.Server() server.start(config.load_paste_app('glance-search'), default_port=9393) server.wait() except KNOWN_EXCEPTIONS as e: fail(e)
def main(): try: config.parse_args() wsgi.set_eventlet_hub() logging.setup(CONF, 'daisy') if cfg.CONF.profiler.enabled: _notifier = osprofiler.notifier.create("Messaging", notifier.messaging, {}, notifier.get_transport(), "daisy", "registry", cfg.CONF.bind_host) osprofiler.notifier.set(_notifier) else: osprofiler.web.disable() server = wsgi.Server() server.start(config.load_paste_app('daisy-registry'), default_port=9191) systemd.notify_once() server.wait() except RuntimeError as e: sys.exit("ERROR: %s" % utils.exception_to_str(e))
def main(): global exitcode opts = [ cfg.SubCommandOpt('server', title='Server types', help='Available server types', handler=add_command_parsers), cfg.StrOpt('pid-file', metavar='PATH', help='File to use as pid file. Default: ' '/var/run/glance/$server.pid.'), cfg.IntOpt('await-child', metavar='DELAY', default=0, help='Period to wait for service death ' 'in order to report exit code ' '(default is to not wait at all).'), cfg.BoolOpt('capture-output', default=False, help='Capture stdout/err in syslog ' 'instead of discarding it.'), cfg.BoolOpt('respawn', default=False, help='Restart service on unexpected death.'), ] CONF.register_cli_opts(opts) config.parse_args(usage=USAGE) @gated_by(CONF.await_child) @gated_by(CONF.respawn) def mutually_exclusive(): sys.stderr.write('--await-child and --respawn are mutually exclusive') sys.exit(1) mutually_exclusive() @gated_by(CONF.respawn) def anticipate_respawn(children): while children: pid, status = os.wait() if pid in children: (pid_file, server, args) = children.pop(pid) running = os.path.exists(pid_file) one_second_ago = time.time() - 1 bouncing = (running and os.path.getmtime(pid_file) >= one_second_ago) if running and not bouncing: args = (pid_file, server, args) new_pid = do_start('Respawn', *args) children[new_pid] = args else: rsn = 'bouncing' if bouncing else 'deliberately stopped' print(_('Suppressed respawn as %(serv)s was %(rsn)s.') % {'serv': server, 'rsn': rsn}) if CONF.server.command == 'start': children = {} for server in CONF.server.servers: pid_file = get_pid_file(server, CONF.pid_file) args = (pid_file, server, CONF.server.args) pid = do_start('Start', *args) children[pid] = args anticipate_respawn(children) if CONF.server.command == 'status': for server in CONF.server.servers: pid_file = get_pid_file(server, CONF.pid_file) do_check_status(pid_file, server) if CONF.server.command == 'stop': for server in CONF.server.servers: do_stop(server, CONF.server.args) if CONF.server.command == 'shutdown': for server in CONF.server.servers: do_stop(server, CONF.server.args, graceful=True) if CONF.server.command == 'restart': for server in CONF.server.servers: do_stop(server, CONF.server.args) for server in CONF.server.servers: pid_file = get_pid_file(server, CONF.pid_file) do_start('Restart', pid_file, server, CONF.server.args) if CONF.server.command in ('reload', 'force-reload'): for server in CONF.server.servers: pid_file = get_pid_file(server, CONF.pid_file) do_reload(pid_file, server) sys.exit(exitcode)