Skip to content

Commit

Permalink
Fix:Override config with environment variables
Browse files Browse the repository at this point in the history
  • Loading branch information
isanwenyu committed Jun 9, 2023
1 parent 85a1103 commit bf2937f
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion config.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,17 @@ def load_config():
if name in available_setting:
logger.info("[INIT] override config by environ args: {}={}".format(name, value))
try:
config[name] = json.loads(value)
#判断系统环境变量是否是json字符串
if '{' in value:
json_dict = json.loads(value)
for key, value in json_dict.items():
if value == "true":
json_dict[key] = True
elif value == "false":
json_dict[key] = False
config[name] = json_dict
else:
config[name] = eval(value)
except:
if value == "false":
config[name] = False
Expand Down

0 comments on commit bf2937f

Please sign in to comment.