docs: update README and CLAUDE.md to v2.2.0
- Added documentation for audit tracking (IP address, invocation method). - Updated database model descriptions for enhanced WorkOrder and Conversation fields. - Documented the new UnifiedConfig system. - Reflected enhanced logging transparency for knowledge base parsing. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -13,15 +13,25 @@ from datetime import datetime
|
||||
# 添加项目根目录到Python路径
|
||||
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
def setup_logging():
|
||||
"""设置日志"""
|
||||
|
||||
def setup_logging(start_time: str):
|
||||
"""设置日志,按启动时间创建子目录"""
|
||||
# 日志根目录
|
||||
log_root = "logs"
|
||||
# 以启动时间命名的子目录(避免路径中的空格和冒号)
|
||||
safe_start_time = start_time.replace(" ", "_").replace(":", "-")
|
||||
log_dir = os.path.join(log_root, safe_start_time)
|
||||
os.makedirs(log_dir, exist_ok=True)
|
||||
|
||||
log_file_path = os.path.join(log_dir, "dashboard.log")
|
||||
|
||||
logging.basicConfig(
|
||||
level=logging.INFO,
|
||||
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
|
||||
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
|
||||
handlers=[
|
||||
logging.FileHandler('logs/dashboard.log', encoding='utf-8'),
|
||||
logging.StreamHandler()
|
||||
]
|
||||
logging.FileHandler(log_file_path, encoding="utf-8"),
|
||||
logging.StreamHandler(),
|
||||
],
|
||||
)
|
||||
|
||||
def start_websocket_server():
|
||||
@@ -52,17 +62,18 @@ def main():
|
||||
print("=" * 60)
|
||||
print("TSP智能助手 - 综合管理平台")
|
||||
print("=" * 60)
|
||||
print(f"启动时间: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}")
|
||||
start_time = datetime.now().strftime("%Y-%m-%d_%H-%M-%S")
|
||||
print(f"启动时间: {start_time}")
|
||||
print()
|
||||
|
||||
# 设置日志
|
||||
setup_logging()
|
||||
# 设置日志(日志目录按启动时间区分)
|
||||
setup_logging(start_time)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
try:
|
||||
# 检查必要目录
|
||||
os.makedirs('logs', exist_ok=True)
|
||||
os.makedirs('data', exist_ok=True)
|
||||
os.makedirs("logs", exist_ok=True)
|
||||
os.makedirs("data", exist_ok=True)
|
||||
|
||||
logger.info("正在启动TSP智能助手综合管理平台...")
|
||||
|
||||
@@ -77,27 +88,32 @@ def main():
|
||||
|
||||
# 导入并启动Flask应用
|
||||
from src.web.app import app
|
||||
|
||||
from src.config.unified_config import get_config
|
||||
|
||||
# 获取配置
|
||||
config = get_config()
|
||||
|
||||
print()
|
||||
print("访问地址:")
|
||||
print(" 主页: http://localhost:5000")
|
||||
print(" 预警管理: http://localhost:5000/alerts")
|
||||
print(" 实时对话: http://localhost:5000/chat")
|
||||
print(" WebSocket: ws://localhost:8765")
|
||||
print(f" 主页: http://localhost:{config.server.port}")
|
||||
print(f" 预警管理: http://localhost:{config.server.port}/alerts")
|
||||
print(f" 实时对话: http://localhost:{config.server.port}/chat")
|
||||
print(f" WebSocket: ws://localhost:{config.server.websocket_port}")
|
||||
print()
|
||||
print("按 Ctrl+C 停止服务")
|
||||
print("=" * 60)
|
||||
|
||||
|
||||
# 在单独线程中启动WebSocket服务器
|
||||
websocket_thread = threading.Thread(target=start_websocket_server, daemon=True)
|
||||
websocket_thread.start()
|
||||
|
||||
|
||||
# 启动Flask应用
|
||||
app.run(
|
||||
debug=False,
|
||||
host='0.0.0.0',
|
||||
port=5000,
|
||||
threaded=True
|
||||
debug=config.server.debug,
|
||||
host=config.server.host,
|
||||
port=config.server.port,
|
||||
threaded=True,
|
||||
use_reloader=False # 禁用重载器,避免重复启动WebSocket服务器
|
||||
)
|
||||
|
||||
except KeyboardInterrupt:
|
||||
|
||||
Reference in New Issue
Block a user