From f39e03fde25ca96e4fb551373666cffb950fa70c Mon Sep 17 00:00:00 2001 From: ben Date: Sat, 6 Sep 2025 07:39:03 +0000 Subject: [PATCH] feat: backup before system reinstall --- .codebuddy/analysis-summary.json | 28 +++++ Coze用户注册功能故障诊断系统.md | 57 ++++++++++ cozeworkflows | 1 + frontend/apps/coze-studio/rsbuild.config.ts | 4 +- start.sh | 116 ++++++++++++++++++++ stop.sh | 100 +++++++++++++++++ 6 files changed, 305 insertions(+), 1 deletion(-) create mode 100644 .codebuddy/analysis-summary.json create mode 100644 Coze用户注册功能故障诊断系统.md create mode 160000 cozeworkflows create mode 100644 start.sh create mode 100644 stop.sh diff --git a/.codebuddy/analysis-summary.json b/.codebuddy/analysis-summary.json new file mode 100644 index 00000000..8de8a704 --- /dev/null +++ b/.codebuddy/analysis-summary.json @@ -0,0 +1,28 @@ +{ + "title": "Coze用户注册功能故障诊断系统", + "features": [ + "系统健康检查", + "前端表单诊断", + "后端接口测试", + "数据库连接验证", + "用户验证逻辑检测", + "实时日志监控", + "问题修复指导" + ], + "tech": { + "Web": { "arch": "react", "component": null }, + "Backend": "Go语言,集成现有coze-studio后端架构", + "Database": "MySQL连接诊断工具", + "Infrastructure": "Docker容器化部署,Minio对象存储" + }, + "design": "Material Design风格的诊断仪表板,采用深蓝色主色调,卡片式布局展示系统状态和诊断结果,包含实时日志监控和问题修复指导界面", + "plan": { + "开发系统健康检查模块,检测前端、后端、数据库、Minio等核心服务状态": "doing", + "构建前端注册表单诊断功能,验证表单验证逻辑和数据提交流程": "holding", + "实现后端注册接口测试工具,检查API响应、参数处理和错误返回": "holding", + "开发数据库连接和用户表诊断功能,验证数据写入和查询权限": "holding", + "构建用户验证逻辑检测模块,测试邮箱验证、密码加密等业务流程": "holding", + "创建诊断结果展示界面,提供问题定位和修复建议": "holding", + "集成实时日志监控和错误追踪功能": "holding" + } +} diff --git a/Coze用户注册功能故障诊断系统.md b/Coze用户注册功能故障诊断系统.md new file mode 100644 index 00000000..6abfb316 --- /dev/null +++ b/Coze用户注册功能故障诊断系统.md @@ -0,0 +1,57 @@ +# Coze用户注册功能故障诊断系统 + +## Core Features + +- 系统健康检查 + +- 前端表单诊断 + +- 后端接口测试 + +- 数据库连接验证 + +- 用户验证逻辑检测 + +- 实时日志监控 + +- 问题修复指导 + +## Tech Stack + +{ + "Web": { + "arch": "react", + "component": null + }, + "Backend": "Go语言,集成现有coze-studio后端架构", + "Database": "MySQL连接诊断工具", + "Infrastructure": "Docker容器化部署,Minio对象存储" +} + +## Design + +Material Design风格的诊断仪表板,采用深蓝色主色调,卡片式布局展示系统状态和诊断结果,包含实时日志监控和问题修复指导界面 + +## Plan + +Note: + +- [ ] is holding +- [/] is doing +- [X] is done + +--- + +[/] 开发系统健康检查模块,检测前端、后端、数据库、Minio等核心服务状态 + +[ ] 构建前端注册表单诊断功能,验证表单验证逻辑和数据提交流程 + +[ ] 实现后端注册接口测试工具,检查API响应、参数处理和错误返回 + +[ ] 开发数据库连接和用户表诊断功能,验证数据写入和查询权限 + +[ ] 构建用户验证逻辑检测模块,测试邮箱验证、密码加密等业务流程 + +[ ] 创建诊断结果展示界面,提供问题定位和修复建议 + +[ ] 集成实时日志监控和错误追踪功能 diff --git a/cozeworkflows b/cozeworkflows new file mode 160000 index 00000000..f86e2274 --- /dev/null +++ b/cozeworkflows @@ -0,0 +1 @@ +Subproject commit f86e22748fc243829de539a09b62dc5850ba9091 diff --git a/frontend/apps/coze-studio/rsbuild.config.ts b/frontend/apps/coze-studio/rsbuild.config.ts index 05e47fc3..689d18b5 100644 --- a/frontend/apps/coze-studio/rsbuild.config.ts +++ b/frontend/apps/coze-studio/rsbuild.config.ts @@ -25,7 +25,8 @@ const API_PROXY_TARGET = `http://localhost:${ const mergedConfig = defineConfig({ server: { - strictPort: true, + port: 3000, + strictPort: false, proxy: [ { context: ['/api'], @@ -103,6 +104,7 @@ const mergedConfig = defineConfig({ 'process.env.RUNTIME_ENTRY': JSON.stringify('@coze-dev/runtime'), 'process.env.TARO_ENV': JSON.stringify('h5'), ENABLE_COVERAGE: JSON.stringify(false), + IS_OVERSEA: JSON.stringify(GLOBAL_ENVS.IS_OVERSEA), }, include: [ path.resolve(__dirname, '../../packages'), diff --git a/start.sh b/start.sh new file mode 100644 index 00000000..cb22123d --- /dev/null +++ b/start.sh @@ -0,0 +1,116 @@ +#!/bin/bash +# +# Copyright 2025 coze-dev Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + + +# Coze Studio 启动脚本 +# 该脚本将启动所有必要的服务 + +set -e + +echo "🚀 正在启动 Coze Studio..." + +# 获取脚本所在目录 +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +cd "$SCRIPT_DIR" + +# 检查是否安装了必要的工具 +echo "📋 检查依赖..." + +# 检查 Docker +if ! command -v docker &> /dev/null; then + echo "❌ Docker 未安装,请先安装 Docker" + exit 1 +fi + +# 检查 Docker Compose +if ! command -v docker-compose &> /dev/null && ! docker compose version &> /dev/null; then + echo "❌ Docker Compose 未安装,请先安装 Docker Compose" + exit 1 +fi + +# 检查 Rush +if ! command -v rush &> /dev/null; then + echo "❌ Rush 未安装,请先安装 Rush" + echo "安装命令: npm install -g @microsoft/rush" + exit 1 +fi + +echo "✅ 依赖检查完成" + +# 启动后端服务 +echo "🔧 启动后端服务..." +cd docker + +# 检查 .env 文件 +if [ ! -f .env ]; then + if [ -f .env.example ]; then + echo "📄 创建 .env 文件..." + cp .env.example .env + echo "⚠️ 请根据需要编辑 .env 文件" + else + echo "⚠️ 未找到 .env.example 文件" + fi +fi + +# 启动 Docker 服务 +echo "🐳 启动 Docker 容器..." +if docker compose version &> /dev/null; then + docker compose up -d +else + docker-compose up -d +fi + +cd .. + +# 等待后端服务启动 +echo "⏳ 等待后端服务启动..." +sleep 10 + +# 安装前端依赖 +echo "📦 安装前端依赖..." +cd frontend +rush update + +echo "🎨 启动前端开发服务器..." +cd apps/coze-studio + +# 增加文件监控限制(解决 ENOSPC 错误) +echo "🔧 配置文件监控限制..." +if [[ "$OSTYPE" == "linux-gnu"* ]]; then + sudo sysctl -w fs.inotify.max_user_watches=524288 2>/dev/null || true +fi + +# 启动前端开发服务器 +PORT=3001 rushx dev & +FRONTEND_PID=$! + +echo "🎉 Coze Studio 启动完成!" +echo "" +echo "📍 前端地址: http://localhost:3001" +echo "📍 API 地址: http://localhost:8888" +echo "📍 文档地址: http://localhost:8888/docs" +echo "" +echo "🔍 查看日志:" +echo " 后端日志: cd docker && docker compose logs -f" +echo " 前端日志: cd frontend/apps/coze-studio && rushx dev" +echo "" +echo "🛑 停止服务:" +echo " 停止所有服务: cd docker && docker compose down" +echo " 停止前端: kill $FRONTEND_PID" + +# 保持脚本运行 +wait $FRONTEND_PID \ No newline at end of file diff --git a/stop.sh b/stop.sh new file mode 100644 index 00000000..a7777341 --- /dev/null +++ b/stop.sh @@ -0,0 +1,100 @@ +#!/bin/bash +# +# Copyright 2025 coze-dev Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + + +# Coze Studio 关闭脚本 +# 该脚本将优雅地停止所有正在运行的服务 + +set -e + +echo "🛑 正在关闭 Coze Studio..." + +# 获取脚本所在目录 +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +cd "$SCRIPT_DIR" + +# 停止前端开发服务器 +echo "🔍 查找并停止前端开发服务器..." +FRONTEND_PIDS=$(pgrep -f "rushx dev" || echo "") +if [ -n "$FRONTEND_PIDS" ]; then + echo "🎯 发现前端进程: $FRONTEND_PIDS" + echo "$FRONTEND_PIDS" | xargs kill -TERM 2>/dev/null || true + sleep 2 + # 强制终止未退出的进程 + echo "$FRONTEND_PIDS" | xargs kill -KILL 2>/dev/null || true + echo "✅ 前端开发服务器已停止" +else + echo "ℹ️ 未发现运行中的前端开发服务器" +fi + +# 停止 Node.js 相关进程 +echo "🔍 查找并停止 Node.js 进程..." +NODE_PIDS=$(pgrep -f "node.*coze-studio" || echo "") +if [ -n "$NODE_PIDS" ]; then + echo "🎯 发现 Node.js 进程: $NODE_PIDS" + echo "$NODE_PIDS" | xargs kill -TERM 2>/dev/null || true + sleep 2 + echo "$NODE_PIDS" | xargs kill -KILL 2>/dev/null || true + echo "✅ Node.js 进程已停止" +else + echo "ℹ️ 未发现运行中的 Node.js 进程" +fi + +# 停止 Docker 容器 +echo "🐳 停止 Docker 容器..." +cd docker + +if docker compose version &> /dev/null; then + if docker compose ps -q | grep -q .; then + echo "🎯 正在停止 Docker 容器..." + docker compose down + echo "✅ Docker 容器已停止" + else + echo "ℹ️ 未发现运行中的 Docker 容器" + fi +else + if docker-compose ps -q | grep -q .; then + echo "🎯 正在停止 Docker 容器..." + docker-compose down + echo "✅ Docker 容器已停止" + else + echo "ℹ️ 未发现运行中的 Docker 容器" + fi +fi + +cd .. + +# 清理临时文件 +echo "🧹 清理临时文件..." +find . -name "node_modules" -type d -prune -exec rm -rf {} + 2>/dev/null || true +find . -name ".next" -type d -prune -exec rm -rf {} + 2>/dev/null || true +find . -name "dist" -type d -prune -exec rm -rf {} + 2>/dev/null || true +find . -name ".turbo" -type d -prune -exec rm -rf {} + 2>/dev/null || true + +echo "✅ 临时文件清理完成" + +# 显示最终状态 +echo "" +echo "📊 服务状态:" +echo "🌐 前端开发服务器: 已停止" +echo "🐳 Docker 容器: 已停止" +echo "🧹 临时文件: 已清理" +echo "" +echo "👋 Coze Studio 已完全关闭!" +echo "" +echo "💡 如果需要重新启动,请运行:" +echo " ./start.sh" \ No newline at end of file