Exemple #1
0
def main():
    xivo_logging.silence_loggers(SPAMMY_LOGGERS, logging.WARNING)

    config = get_config(sys.argv[1:])

    xivo_logging.setup_logging(
        config['log_filename'],
        config['foreground'],
        config['debug'],
        config['log_level'],
    )

    user = config.get('user')
    if user:
        change_user(user)

    try:
        set_xivo_uuid(config, logger)
    except UUIDNotFound:
        if config['service_discovery']['enabled']:
            raise

    controller = Controller(config)
    with pidfile_context(config['pid_filename'], config['foreground']):
        try:
            controller.run()
        except KeyboardInterrupt:
            pass
Exemple #2
0
def main(argv=None):
    argv = argv or sys.argv[1:]
    with _PreConfigLogger() as logger:
        logger.debug('Starting wazo-dird')

        config = load_config(logger, argv)

        xivo_logging.setup_logging(config['log_filename'], config['foreground'],
                                   config['debug'], config['log_level'])
    xivo_logging.silence_loggers(['Flask-Cors', 'urllib3', 'stevedore.extension'], logging.WARNING)

    if config['user']:
        change_user(config['user'])

    try:
        set_xivo_uuid(config, logger)
    except UUIDNotFound:
        if config['service_discovery']['enabled']:
            raise

    controller = Controller(config)

    with pidfile_context(config['pid_filename'], config['foreground']):
        try:
            controller.run()
        except KeyboardInterrupt:
            # exit without stack trace
            pass
Exemple #3
0
def main():
    _print_deprecation_notice()
    setup_logging('/dev/null', foreground=True, debug=False)
    silence_loggers(['urllib3.connectionpool'], level=logging.WARNING)
    init_db_from_config(default_config())
    with pidfile_context(PIDFILENAME, foreground=True):
        _generate_call_logs()
Exemple #4
0
def main():
    cli_config = _parse_args()
    file_config = read_config_file_hierarchy(
        ChainMap(cli_config, _DEFAULT_CONFIG))
    service_key = _load_key_file(
        ChainMap(cli_config, file_config, _DEFAULT_CONFIG))
    config = ChainMap(cli_config, service_key, file_config, _DEFAULT_CONFIG)

    user = config.get('user')
    if user:
        change_user(user)

    xivo_dao.init_db_from_config(config)

    setup_logging(config['logfile'], config['foreground'], config['debug'])
    silence_loggers(['Flask-Cors'], logging.WARNING)
    set_xivo_uuid(config, logger)

    with pidfile_context(config['pidfile'], config['foreground']):
        logger.info('Starting xivo-agentd')
        try:
            _run(config)
        except Exception:
            logger.exception('Unexpected error:')
        except KeyboardInterrupt:
            pass
        finally:
            logger.info('Stopping xivo-agentd')
Exemple #5
0
def main(argv=None):
    argv = argv or sys.argv[1:]
    config = load_config(argv)

    if config['user']:
        change_user(config['user'])

    xivo_logging.setup_logging(config['log_filename'], config['foreground'],
                               config['debug'], config['log_level'])
    xivo_logging.silence_loggers(
        [
            'amqp', 'Flask-Cors', 'iso8601', 'kombu', 'swaggerpy', 'urllib3',
            'ari.model', 'stevedore.extension'
        ],
        logging.WARNING,
    )
    if config['debug']:
        xivo_logging.silence_loggers(['swaggerpy'], logging.INFO)

    set_xivo_uuid(config, logger)

    controller = Controller(config)
    signal.signal(signal.SIGTERM, partial(sigterm, controller))

    with pidfile_context(config['pid_filename'], config['foreground']):
        controller.run()
Exemple #6
0
def main():
    parsed_args = _parse_args()

    setup_logging(LOG_FILE_NAME, parsed_args.foreground, parsed_args.debug)

    with pidfile_context(PIDFILE, parsed_args.foreground):
        agid.init()
        agid.run()
Exemple #7
0
def main(argv):
    config = load_config(argv)

    setup_logging(config['log_filename'], config['foreground'], config['debug'], config['log_level'])
    if config['user']:
        change_user(config['user'])

    controller = Controller(config)

    with pidfile_context(config['pid_filename'], config['foreground']):
        controller.run()
Exemple #8
0
def main():
    cli_config = _parse_args()
    file_config = read_config_file_hierarchy(ChainMap(cli_config, _DEFAULT_CONFIG))
    config = ChainMap(cli_config, file_config, _DEFAULT_CONFIG)

    setup_logging(config['logfile'], config['foreground'], config['debug'])
    silence_loggers(['urllib3'], logging.WARNING)

    xivo_dao.init_db_from_config(config)

    with pidfile_context(config['pidfile'], config['foreground']):
        agid.init(config)
        agid.run()
Exemple #9
0
def main():
    config = load_config(sys.argv[1:])

    if config.get('user'):
        change_user(config['user'])

    xivo_logging.setup_logging(config['log_filename'], config['foreground'],
                               config['debug'], config['log_level'])

    controller = Controller(config)

    with pidfile_context(config['pid_filename'], config['foreground']):
        controller.run()
Exemple #10
0
def main():
    cli_config = _parse_args()
    file_config = read_config_file_hierarchy(ChainMap(cli_config, _DEFAULT_CONFIG))
    config = ChainMap(cli_config, file_config, _DEFAULT_CONFIG)

    setup_logging(config['log_file'], debug=config['debug'])

    xivo_dao.init_db_from_config(config)

    with pidfile_context(config['pid_file']):
        if 'archives' in config.get('enabled_plugins', {}):
            _load_plugins(config)
        _purge_tables(config)
Exemple #11
0
def main(argv):
    config = load_config(argv)

    if config['user']:
        change_user(config['user'])

    xivo_logging.setup_logging(config['log_filename'], config['foreground'], config['debug'], config['log_level'])
    xivo_logging.silence_loggers(['amqp', 'Flask-Cors', 'iso8601', 'kombu', 'swaggerpy', 'urllib3', 'ari.model'], logging.WARNING)

    set_xivo_uuid(config, logger)

    controller = Controller(config)
    signal.signal(signal.SIGTERM, partial(sigterm, controller))

    with pidfile_context(config['pid_filename'], config['foreground']):
        controller.run()
Exemple #12
0
def main():
    conf = config.load_config(sys.argv[1:])

    if conf['user']:
        change_user(conf['user'])

    xivo_logging.setup_logging(conf['log_file'], FOREGROUND, conf['debug'],
                               conf['log_level'])
    xivo_logging.silence_loggers(
        ['Flask-Cors', 'urllib3', 'stevedore.extension'], logging.WARNING)

    set_xivo_uuid(conf, logger)

    controller = Controller(conf)
    with pidfile_context(conf['pid_file'], FOREGROUND):
        controller.run()
Exemple #13
0
def main(argv):
    config = load_config(argv)

    user = config.get('user')
    if user:
        change_user(user)

    setup_logging(config['logfile'], config['foreground'], config['debug'],
                  config['log_level'])
    xivo_dao.init_db_from_config(config)

    set_xivo_uuid(config, logger)

    controller = Controller(config)
    signal.signal(signal.SIGTERM, partial(sigterm, controller))

    with pidfile_context(config['pidfile'], config['foreground']):
        controller.run()
Exemple #14
0
def main(argv):
    config = load_config(argv)

    xivo_logging.setup_logging(config['log_filename'], config['foreground'],
                               config['debug'], config['log_level'])
    xivo_logging.silence_loggers(['Flask-Cors'], logging.WARNING)

    if config['user']:
        change_user(config['user'])

    xivo_dao.init_db_from_config(config)
    init_bus_from_config(ChainMap(config, {'uuid': info_dao.get().uuid}))
    setup_sysconfd(config['sysconfd']['host'], config['sysconfd']['port'])

    controller = Controller(config)

    with pidfile_context(config['pid_filename'], config['foreground']):
        controller.run()
Exemple #15
0
def main():
    conf = config.load_config(sys.argv[1:])

    if conf['user']:
        change_user(conf['user'])

    xivo_logging.setup_logging(conf['log_file'], FOREGROUND, conf['debug'],
                               conf['log_level'])
    xivo_logging.silence_loggers(['Flask-Cors', 'urllib3'], logging.WARNING)

    try:
        set_xivo_uuid(conf, logger)
    except UUIDNotFound:
        # handled in the controller
        pass

    controller = Controller(conf)
    with pidfile_context(conf['pid_file'], FOREGROUND):
        controller.run()
Exemple #16
0
def main(argv):
    config = load_config(argv)

    xivo_logging.setup_logging(config['log_filename'], config['foreground'],
                               config['debug'], config['log_level'])
    xivo_logging.silence_loggers(['Flask-Cors'], logging.WARNING)

    if config['user']:
        change_user(config['user'])

    try:
        set_xivo_uuid(config, logger)
    except UUIDNotFound:
        if config['service_discovery']['enabled']:
            raise

    controller = Controller(config)

    with pidfile_context(config['pid_filename'], config['foreground']):
        controller.run()
Exemple #17
0
def main(args):
    conf = config.load_config(args)

    xivo_logging.setup_logging(conf['log_file'], FOREGROUND, conf['debug'], conf['log_level'])

    os.chdir(conf['home_dir'])

    with RootWorker() as root_worker:
        if conf['user']:
            change_user(conf['user'])

        try:
            set_xivo_uuid(conf, logger)
        except UUIDNotFound:
            # handled in the controller
            pass

        controller = Controller(conf, root_worker)
        with pidfile_context(conf['pid_file'], FOREGROUND):
            logger.debug('starting')
            controller.run()
            logger.debug('controller stopped')
        logger.debug('done')
Exemple #18
0
def main():
    log_format = '%(asctime)s: %(message)s'
    main_config = config.get_config()
    init_db_from_config(main_config)
    setup_logging(main_config['log_filename'],
                  debug=main_config['debug'],
                  log_format=log_format)

    with pidfile_context(PIDFILENAME):
        parser = argparse.ArgumentParser(
            description='Wazo statistics generator')
        options = parse_args(parser)
        subcommand = getattr(options, 'subcommand', None)

        if subcommand == 'fill_db':
            core.update_db(
                config=main_config,
                start_date=options.start,
                end_date=options.end,
            )
        elif subcommand == 'clean_db':
            core.clean_db()
        else:
            parser.print_help()
Exemple #19
0
    def test_that_unlock_is_called(self, _lock_fn, unlock_fn):
        with daemonize.pidfile_context(sentinel.filename):
            pass

        unlock_fn.assert_called_once_with(sentinel.filename)
Exemple #20
0
 def f():
     with daemonize.pidfile_context(sentinel.filename):
         raise Exception('ok')
def main():
    _print_deprecation_notice()
    setup_logging('/dev/null', debug=False)
    silence_loggers(['urllib3.connectionpool'], level=logging.WARNING)
    with pidfile_context(PIDFILENAME):
        _generate_call_logs()