service.py 文件源码

python
阅读 37 收藏 0 点赞 0 评论 0

项目:galaxia 作者: WiproOpenSourcePractice 项目源码 文件源码
def prepare_service(service_name, argv=[]):
    """
    Initializes the various galaxia services
    :param service_name: Name of the service
    :param argv: Configuration file
    :return:
    """

    cfg.CONF(argv[1:], project='galaxia')

    opt_group = cfg.OptGroup(name=service_name, title='Logging options for\
                                                      the service')
    cfg.CONF.register_group(opt_group)
    cfg.CONF.register_opts(LOGGING_SERVICE_OPTS, opt_group)

    log_file = cfg.CONF._get("log_file", group=opt_group)
    log_level = cfg.CONF._get("log_level", group=opt_group)

    log_helper.setup_logging(log_file, log_level)

    db_group = cfg.OptGroup(name='db', title='Options for the database')
    cfg.CONF.register_group(db_group)
    cfg.CONF.register_opts(DB_SERVICE_OPTS, db_group)
    cfg.CONF.set_override('db_host', cfg.CONF.db.db_host, db_group)
    cfg.CONF.set_override('type', cfg.CONF.db.type, db_group)
    cfg.CONF.set_override('db_location', cfg.CONF.db.db_location, db_group)

    sql_helper.init_db(cfg.CONF.db.type, cfg.CONF.db.username,
                       cfg.CONF.db.password, cfg.CONF.db.db_host, "galaxia", cfg.CONF.db.db_location)
    load_mapping.initialize()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号