From 13a40495e4e070336a307d0779db21fae8b1b674 Mon Sep 17 00:00:00 2001 From: flying-hero <462087392@qq.com> Date: Sat, 4 Apr 2026 19:16:22 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9A=20=E6=96=B0=E5=A2=9E=E9=83=A8?= =?UTF-8?q?=E7=BD=B2=E6=96=87=E6=A1=A3=20DEPLOY.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 内容: - 快速启动步骤 - 常见问题排查 - 配置文件说明 - 最佳实践建议 帮助避免部署问题 --- DEPLOY.md | 118 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 DEPLOY.md diff --git a/DEPLOY.md b/DEPLOY.md new file mode 100644 index 0000000..e6d5e9f --- /dev/null +++ b/DEPLOY.md @@ -0,0 +1,118 @@ +# 🦀 龙虾监控中心 - 部署指南 + +## 📋 服务架构 + +``` +前端 (React) 后端 (Django) + ↓ ↓ +端口 4000 端口 9000 + ↓ ↓ +build/静态文件 API 服务 +``` + +## 🚀 快速启动 + +### 1. 启动后端 + +```bash +cd code/backend +source venv/bin/activate +python manage.py runserver 0.0.0.0:9000 +``` + +### 2. 构建并启动前端 + +```bash +cd code/frontend +npm run build +cd build +python3 -m http.server 4000 --bind 127.0.0.1 +``` + +### 3. 访问 + +- 前端:http://localhost:4000/ +- 后端 API: http://localhost:9000/api/ + +## ⚠️ 常见问题 + +### Q: 前端显示"加载中..." +**A**: 检查后端是否在 9000 端口运行 +```bash +curl http://localhost:9000/api/agents/ +``` + +### Q: API 返回 404 +**A**: 确认前端 API 配置正确 +- 检查 `src/pages/Dashboard/index.js` 中的 `API_BASE` +- 应该是 `http://localhost:9000/api` + +### Q: 代码改了但不生效 +**A**: 需要重新 build 前端 +```bash +cd code/frontend +npm run build # 重新构建 +# 然后重启前端服务 +``` + +## 🔧 配置文件 + +### 前端 API 配置 +文件:`code/frontend/src/pages/Dashboard/index.js` +```javascript +const API_BASE = 'http://localhost:9000/api'; +``` + +### 后端端口 +文件:`code/backend/backend/settings.py` +```bash +# 启动时指定端口 +python manage.py runserver 0.0.0.0:9000 +``` + +## 📦 依赖安装 + +### 后端 +```bash +cd code/backend +python3 -m venv venv +source venv/bin/activate +pip install -r requirements.txt +``` + +### 前端 +```bash +cd code/frontend +npm install +``` + +## 🎯 最佳实践 + +1. **启动前先 git pull** + ```bash + git pull origin main + ``` + +2. **前端修改后重新 build** + ```bash + npm run build + ``` + +3. **后端修改后重启服务** + ```bash + # Ctrl+C 停止 + # 重新启动 + ``` + +4. **检查服务状态** + ```bash + # 检查后端 + curl http://localhost:9000/api/agents/ + + # 检查前端 + curl http://localhost:4000/ + ``` + +--- + +*最后更新:2026-04-04*