Files
openclaw-monitor/docs/部署指南.md
flying-hero 4be901b1b0 Complete backend API and deployment guide
- Django REST API with lobster endpoints
- API views: list, detail, memory, tools
- Deployment guide with instructions
- Startup script for easy launch
- Requirements.txt for dependencies
- API URL routing
2026-04-01 20:52:03 +08:00

1.8 KiB
Raw Permalink Blame History

部署指南

🚀 快速部署

1. 安装依赖

后端

cd code/backend
pip3 install -r requirements.txt

前端

cd code/frontend
npm install

2. 启动服务

方法一:使用启动脚本

chmod +x start.sh
./start.sh

方法二:手动启动

# 启动后端
cd code/backend
python3 manage.py runserver 0.0.0.0:8000

# 启动前端(新终端)
cd code/frontend
npm start
# 或
python3 -m http.server 3000

3. 访问

📊 API 接口

获取龙虾列表

curl http://localhost:8000/api/lobsters/

获取龙虾详情

curl http://localhost:8000/api/lobsters/1/

获取龙虾记忆

curl http://localhost:8000/api/lobsters/1/memory/

获取工具列表

curl http://localhost:8000/api/tools/

🔧 配置

环境变量

  • DEBUG: 调试模式(默认 True
  • SECRET_KEY: Django 密钥
  • ALLOWED_HOSTS: 允许的主机

数据库

默认使用 SQLite无需配置。

📝 日志

  • 后端日志:终端输出
  • 前端日志:浏览器控制台

🐛 故障排查

端口被占用

# 查看占用端口的进程
lsof -i :8000
lsof -i :3000

# 杀死进程
kill -9 <PID>

依赖问题

# 重新安装依赖
pip3 install -r requirements.txt --force-reinstall
npm install --force

📦 生产部署

使用 Gunicorn

pip3 install gunicorn
gunicorn backend.wsgi:application --bind 0.0.0.0:8000

使用 Nginx 反向代理

server {
    listen 80;
    server_name your-domain.com;

    location / {
        proxy_pass http://localhost:3000;
    }

    location /api/ {
        proxy_pass http://localhost:8000;
    }
}