def main(): args = _parse_cli_args(sys.argv[1:]) if args.user: change_user(args.user) for _ in range(40): try: conn = psycopg2.connect(args.pg_db_uri) break except psycopg2.OperationalError: time.sleep(0.25) else: print('Failed to connect to postgres', file=sys.stderr) sys.exit(1) conn.autocommit = True with conn: with conn.cursor() as cursor: if not db_helper.db_user_exists(cursor, args.owner): db_helper.create_db_user(cursor, args.owner, args.password) if not db_helper.db_exists(cursor, args.db): db_helper.create_db(cursor, args.db, args.owner) conn = psycopg2.connect(args.auth_db_uri) with conn: with conn.cursor() as cursor: db_helper.create_db_extensions(cursor, ['uuid-ossp'])
def main(): xivo_logging.silence_loggers(SPAMMY_LOGGERS, logging.WARNING) config = get_config(sys.argv[1:]) xivo_logging.setup_logging( config['log_filename'], debug=config['debug'], log_level=config['log_level'], ) if config['user']: change_user(config['user']) if config["db_upgrade_on_startup"]: database.upgrade(config["db_uri"]) try: set_xivo_uuid(config, logger) except UUIDNotFound: if config['service_discovery']['enabled']: raise controller = Controller(config) controller.run()
def main(argv=None): argv = argv or sys.argv[1:] with _PreConfigLogger() as logger: logger.debug('Starting wazo-dird') config = load_config(argv) xivo_logging.setup_logging( config['log_filename'], debug=config['debug'], log_level=config['log_level'], ) xivo_logging.silence_loggers( ['Flask-Cors', 'amqp', '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) controller.run()
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'], debug=config['debug'], log_level=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)) controller.run()
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
def main(): cti_config.init_cli_config(sys.argv[1:]) cti_config.init_config_file() cti_config.init_auth_config() xivo_dao.init_db_from_config(config) cti_config.update_db_config() user = config.get('user') if user: change_user(user) setup_logging(config['logfile'], config['foreground'], config['debug']) silence_loggers( ['amqp', 'urllib3', 'Flask-Cors', 'kombu', 'stevedore.extension'], logging.WARNING) xivo_uuid = get_xivo_uuid(logger) register_class.setup(xivo_uuid) ctid = context.get('cti_server') ctid.setup() with ServiceCatalogRegistration('xivo-ctid', xivo_uuid, config['consul'], config['service_discovery'], config['bus'], partial(self_check, config)): ctid.run()
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
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')
def main(): parser = argparse.ArgumentParser(description='Call logs database migrator') options = parse_args(parser) file_config = { key: value for key, value in read_config_file_hierarchy(DEFAULT_CONFIG).items() if key in ('db_uri', 'cel_db_uri') } config = ChainMap(file_config, DEFAULT_CONFIG) if config['user']: change_user(config['user']) setup_logging( config['logfile'], debug=config['debug'] or options.debug, log_level=get_log_level_by_name(config['log_level']), ) options = vars(options) if options.get('action') == 'call-log': if options.get('index'): migrate_call_log_index(config) else: migrate_call_log_tables(config, options.get('max_entries'))
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()
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()
def main(): config = load_config(sys.argv[1:]) if config.get('user'): change_user(config['user']) xivo_logging.setup_logging( config['log_filename'], debug=config['debug'], log_level=config['log_level'], ) controller = Controller(config) controller.run()
def main(): config = load_config() setup_logging(config['logfile'], debug=config['debug']) if config.get('user'): change_user(config['user']) set_xivo_uuid(config, logger) controller = Controller(config) signal.signal(signal.SIGTERM, partial(sigterm, controller)) controller.run()
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()
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()
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()
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()
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()
def main(): argv = sys.argv[1:] config = load_config(argv) if config['user']: change_user(config['user']) setup_logging( config['logfile'], debug=config['debug'], log_level=config['log_level'] ) silence_loggers(['amqp'], level=logging.WARNING) if config["db_upgrade_on_startup"]: database.upgrade(config["db_uri"]) xivo_dao.init_db_from_config({'db_uri': config['cel_db_uri']}) set_xivo_uuid(config, logger) controller = Controller(config) controller.run()
def main(argv=None): argv = argv or sys.argv[1:] with _PreConfigLogger() as logger: logger.debug('Starting wazo-phoned') config = load_config(logger, argv) setup_logging( config['log_filename'], debug=config['debug'], log_level=config['log_level'], ) silence_loggers(['amqp'], logging.WARNING) if config['user']: change_user(config['user']) controller = Controller(config) signal.signal(signal.SIGTERM, partial(sigterm, controller)) controller.run()
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()
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()
def main(): config = load_config() xivo_logging.setup_logging(config['log_file'], debug=config['debug'], log_level=config['log_level']) xivo_logging.silence_loggers(['urllib3'], logging.WARNING) xivo_logging.silence_loggers(['aioamqp'], logging.WARNING) if config['user']: change_user(config['user']) create_or_update_exchange(config['bus']) authenticator = Authenticator(config) bus_service = BusService(config['bus']) protocol_encoder = SessionProtocolEncoder() protocol_decoder = SessionProtocolDecoder() session_factory = SessionFactory(config, authenticator, bus_service, protocol_encoder, protocol_decoder) controller = Controller(config, session_factory, bus_service) controller.setup() controller.run()
def main(): config = _read_config() setup_logging(config['log_filename'], debug=config['debug']) if 'host' not in config['prov_server']: logger.error('error: no provd host specified. Exiting.') sys.exit(1) user = config['user'] if user: change_user(user) auth_client = AuthClient(**config['auth']) provd_client = ProvdClient(**config['prov_server']) token_renewer = TokenRenewer(auth_client) token_renewer.subscribe_to_token_change(provd_client.set_token) sink = ProvServerDHCPInfoSink(provd_client) with token_renewer: try: pidfile = PidFile(config['pid_filename']) try: source = UnixSocketDHCPInfoSource(config['unix_server_addr'], True) try: signum = signal.SIGTERM old_handler = signal.signal(signum, _sig_handler) try: agent = Agent(source, sink) agent.run() finally: signal.signal(signum, old_handler) finally: source.close() finally: pidfile.close() finally: sink.close()
def main(argv=None): argv = argv or sys.argv[1:] config = load_config(argv) xivo_logging.setup_logging( config['log_filename'], debug=config['debug'], log_level=config['log_level'], ) xivo_logging.silence_loggers(['Flask-Cors'], logging.WARNING) xivo_logging.silence_loggers(['amqp'], logging.INFO) if config['user']: change_user(config['user']) try: set_xivo_uuid(config, logger) except UUIDNotFound: if config['service_discovery']['enabled']: raise controller = Controller(config) controller.run()
def main(): xivo_logging.silence_loggers(SPAMMY_LOGGERS, logging.WARNING) config = get_config(sys.argv[1:]) xivo_logging.setup_logging( config['log_filename'], debug=config['debug'], log_level=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) controller.run()
def main(argv=None): argv = argv or sys.argv[1:] config = load_config(logger, argv) user = config.get('user') if user: change_user(user) xivo_dao.init_db_from_config(config) setup_logging(config['logfile'], debug=config['debug']) silence_loggers(['Flask-Cors', 'amqp'], logging.WARNING) set_xivo_uuid(config, logger) logger.info('Starting wazo-agentd') try: _run(config) except Exception: logger.exception('Unexpected error:') except KeyboardInterrupt: pass finally: logger.info('Stopping wazo-agentd')
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')
def main(): cli_config = _parse_args() file_config = read_config_file_hierarchy( ChainMap(cli_config, _DEFAULT_CONFIG)) key_config = _load_key_file( ChainMap(cli_config, file_config, _DEFAULT_CONFIG)) config = ChainMap(cli_config, key_config, file_config, _DEFAULT_CONFIG) setup_logging(config['logfile'], debug=config['debug']) silence_loggers(['urllib3'], logging.WARNING) user = config.get('user') if user: change_user(user) xivo_dao.init_db_from_config(config) token_renewer = TokenRenewer(AuthClient(**config['auth'])) config['agentd']['client'] = AgentdClient(**config['agentd']) config['calld']['client'] = CalldClient(**config['calld']) config['confd']['client'] = ConfdClient(**config['confd']) config['dird']['client'] = DirdClient(**config['dird']) config['auth']['client'] = AuthClient(**config['auth']) def on_token_change(token_id): config['agentd']['client'].set_token(token_id) config['calld']['client'].set_token(token_id) config['confd']['client'].set_token(token_id) config['dird']['client'].set_token(token_id) config['auth']['client'].set_token(token_id) token_renewer.subscribe_to_token_change(on_token_change) agid.init(config) with token_renewer: agid.run()