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