update:重新规划私有文件的存储目录

This commit is contained in:
hrz
2025-02-16 10:37:43 +08:00
parent 3f19c518d3
commit ed7fea0b46
8 changed files with 17 additions and 13 deletions
+2 -2
View File
@@ -5,7 +5,7 @@ __pycache__
Dockerfile
docs/
tmp/
data/
LICENSE
README.md
README_en.md
.config.yaml
README_en.md
+3 -2
View File
@@ -324,8 +324,9 @@ pip install -r requirements.txt
```
# 如果您是一名开发者,建议阅读以下内容。如果不是开发者,可以忽略这部分内容。
在开发中,建议将【config.yaml】复制一份,改成【.config.yaml】。 系统会优先读取【.config.yaml】文件的配置。
这样做,可以避免在提交代码的时候,错误地提交密钥信息,保护您的密钥安全
# 在开发中,在项目根目录创建data目录,将【config.yaml】复制一份,改成【.config.yaml】,放进data目录中
# 系统会优先读取【data/.config.yaml】文件的配置
# 这样做,可以避免在提交代码的时候,错误地提交密钥信息,保护您的密钥安全。
```
配置说明:这里是各个功能使用的默认组件,例如LLM默认使用`ChatGLMLLM`模型。如果需要切换模型,就是改对应的名称。
+2 -1
View File
@@ -1,5 +1,6 @@
# 如果您是一名开发者,建议阅读以下内容。如果不是开发者,可以忽略这部分内容。
# 在开发中,建议将【config.yaml】复制一份,改成【.config.yaml】。 系统会优先读取【.config.yaml】文件的配置。
# 在开发中,在项目根目录创建data目录,将【config.yaml】复制一份,改成【.config.yaml】,放进data目录中
# 系统会优先读取【data/.config.yaml】文件的配置。
# 这样做,可以避免在提交代码的时候,错误地提交密钥信息,保护您的密钥安全。
# 服务器基础配置(Basic server configuration)
+2 -1
View File
@@ -3,9 +3,10 @@ import sys
import os
def setup_logging(log_dir='tmp'):
def setup_logging(log_dir='tmp', data_dir='data'):
"""配置全局日志"""
os.makedirs(log_dir, exist_ok=True)
os.makedirs(data_dir, exist_ok=True)
logging.basicConfig(
level=logging.INFO,
+1 -1
View File
@@ -11,7 +11,7 @@ class PrivateConfig:
def __init__(self, device_id: str, default_config: Dict[str, Any]):
self.device_id = device_id
self.default_config = default_config
self.config_path = get_project_dir() + '.private_config.yaml'
self.config_path = get_project_dir() + 'data/.private_config.yaml'
self.logger = logging.getLogger(__name__)
self.private_config = {}
+1 -1
View File
@@ -13,7 +13,7 @@ docker build -t xiaozhi-esp32-server:local -f ./Dockerfile .
docker stop xiaozhi-esp32-server
docker rm xiaozhi-esp32-server
docker run -d --name xiaozhi-esp32-server --restart always -p 8000:8000 -v $(pwd)/.config.yaml:/opt/xiaozhi-esp32-server/config.yaml xiaozhi-esp32-server:local
docker run -d --name xiaozhi-esp32-server --restart always -p 8000:8000 -v $(pwd)/data/.config.yaml:/opt/xiaozhi-esp32-server/config.yaml xiaozhi-esp32-server:local
docker logs -f xiaozhi-esp32-server
+3 -4
View File
@@ -2,7 +2,6 @@ import os
import yaml
import logging
from aiohttp import web
from typing import Dict, Any
from core.utils.util import get_project_dir
from config.private_config import PrivateConfig
@@ -10,11 +9,11 @@ logger = logging.getLogger(__name__)
class ConfigHandler:
def __init__(self):
self.private_config_path = get_project_dir() + '.private_config.yaml'
self.private_config_path = get_project_dir() + 'data/.private_config.yaml'
self.config_path = get_project_dir() + 'config.yaml'
# 如果存在.config.yaml文件,则使用该文件
if os.path.exists(get_project_dir() + ".config.yaml"):
self.config_path = get_project_dir() + ".config.yaml"
if os.path.exists(get_project_dir() + "data/.config.yaml"):
self.config_path = get_project_dir() + "data/.config.yaml"
with open(self.config_path, 'r', encoding='utf-8') as f:
self.config = yaml.safe_load(f)
+3 -1
View File
@@ -2,12 +2,14 @@ import os
import yaml
import hashlib
import logging
from core.utils.util import get_project_dir
logger = logging.getLogger(__name__)
class UserManager:
def __init__(self):
self.secrets_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), '.secrets.yaml')
self.secrets_path = get_project_dir() + 'data/.secrets.yaml'
self.users = {}
self.ensure_secrets_file()
self.load_user_data()