0
我有一个.conf文件,我不想在进程启动时通过cmd行(--config-file)传递。相反,我希望它动态加载。有没有办法加载配置文件?
我使用oslo_config库来注册配置选项,我需要由oslo_config库解析conf文件。
PS:因为这个oslo_config CONF对象已经在我的多进程框架中传播了,所以我不想使用像ConfigParser之类的其他库。
谢谢。
我有一个.conf文件,我不想在进程启动时通过cmd行(--config-file)传递。相反,我希望它动态加载。有没有办法加载配置文件?
我使用oslo_config库来注册配置选项,我需要由oslo_config库解析conf文件。
PS:因为这个oslo_config CONF对象已经在我的多进程框架中传播了,所以我不想使用像ConfigParser之类的其他库。
谢谢。
只是初始化另一个olslo_config.cfg.ConfigOpts()实例
self.conf = cfg.ConfigOpts()
self.conf(
sys.argv[1:], # if there is, can be []
project="whatever", # but will affect the searching directories
default_config_files=["path/to/my/conf"] # if not set, will do a auto searching
)
# use it via self.conf.example_section.example_option