mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-26 00:53:54 +08:00
Merge branch 'main' into py_fix_log
This commit is contained in:
@@ -1,14 +1,9 @@
|
||||
import os
|
||||
import argparse
|
||||
import yaml
|
||||
from collections.abc import Mapping
|
||||
from config.manage_api_client import init_service, get_server_config, get_agent_models
|
||||
|
||||
|
||||
# 添加全局配置缓存
|
||||
_config_cache = None
|
||||
|
||||
|
||||
def get_project_dir():
|
||||
"""获取项目根目录"""
|
||||
return os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + "/"
|
||||
@@ -22,9 +17,12 @@ def read_config(config_path):
|
||||
|
||||
def load_config():
|
||||
"""加载配置文件"""
|
||||
global _config_cache
|
||||
if _config_cache is not None:
|
||||
return _config_cache
|
||||
from core.utils.cache.manager import cache_manager, CacheType
|
||||
|
||||
# 检查缓存
|
||||
cached_config = cache_manager.get(CacheType.CONFIG, "main_config")
|
||||
if cached_config is not None:
|
||||
return cached_config
|
||||
|
||||
default_config_path = get_project_dir() + "config.yaml"
|
||||
custom_config_path = get_project_dir() + "data/.config.yaml"
|
||||
@@ -40,7 +38,9 @@ def load_config():
|
||||
config = merge_configs(default_config, custom_config)
|
||||
# 初始化目录
|
||||
ensure_directories(config)
|
||||
_config_cache = config
|
||||
|
||||
# 缓存配置
|
||||
cache_manager.set(CacheType.CONFIG, "main_config", config)
|
||||
return config
|
||||
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ from config.config_loader import load_config
|
||||
from config.settings import check_config_file
|
||||
from datetime import datetime
|
||||
|
||||
SERVER_VERSION = "0.6.3"
|
||||
SERVER_VERSION = "0.7.1"
|
||||
_logger_initialized = False
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user