mirror of
https://github.com/woodchen-ink/dnspod-yxip.git
synced 2025-07-18 05:42:08 +08:00
修复bug
This commit is contained in:
parent
857dd3a0cd
commit
c39781d4dc
@ -18,7 +18,7 @@ COPY main.py .
|
|||||||
RUN pip install -r requirements.txt
|
RUN pip install -r requirements.txt
|
||||||
|
|
||||||
# 创建配置文件和日志目录
|
# 创建配置文件和日志目录
|
||||||
RUN mkdir -p logs && touch .env
|
RUN mkdir -p logs && touch config.yaml
|
||||||
|
|
||||||
# 运行程序
|
# 运行程序
|
||||||
CMD ["python", "main.py"]
|
CMD ["python", "main.py"]
|
18
config.py
18
config.py
@ -1,6 +1,7 @@
|
|||||||
import os
|
import os
|
||||||
from typing import Dict, List
|
from typing import Dict, List
|
||||||
import yaml
|
import yaml
|
||||||
|
from loguru import logger
|
||||||
|
|
||||||
# 加载YAML配置
|
# 加载YAML配置
|
||||||
def load_config() -> Dict:
|
def load_config() -> Dict:
|
||||||
@ -8,8 +9,21 @@ def load_config() -> Dict:
|
|||||||
yaml_files = ["config.yaml", "config.example.yaml"]
|
yaml_files = ["config.yaml", "config.example.yaml"]
|
||||||
for yaml_file in yaml_files:
|
for yaml_file in yaml_files:
|
||||||
if os.path.exists(yaml_file):
|
if os.path.exists(yaml_file):
|
||||||
with open(yaml_file, "r", encoding="utf-8") as f:
|
try:
|
||||||
return yaml.safe_load(f)
|
with open(yaml_file, "r", encoding="utf-8") as f:
|
||||||
|
config = yaml.safe_load(f)
|
||||||
|
logger.info(f"成功加载配置文件: {yaml_file}")
|
||||||
|
# 验证必要的配置项
|
||||||
|
if not config.get("tencent", {}).get("secret_id"):
|
||||||
|
logger.error(f"配置文件 {yaml_file} 中缺少必要的配置项: tencent.secret_id")
|
||||||
|
return {}
|
||||||
|
if not config.get("tencent", {}).get("secret_key"):
|
||||||
|
logger.error(f"配置文件 {yaml_file} 中缺少必要的配置项: tencent.secret_key")
|
||||||
|
return {}
|
||||||
|
return config
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"加载配置文件 {yaml_file} 失败: {str(e)}")
|
||||||
|
logger.error("未找到有效的配置文件")
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
# 加载配置
|
# 加载配置
|
||||||
|
Loading…
x
Reference in New Issue
Block a user