Files
cursornew2026/backend/DEPLOY.md

124 lines
2.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 蜂鸟CursorPro 后端部署指南
## 1. 上传文件
将整个 `backend/` 目录上传到服务器,例如 `/opt/cursorpro/`
## 2. 安装依赖
```bash
cd /opt/cursorpro
pip3 install -r requirements.txt
```
## 3. 修改配置
编辑 `app/config.py`
```python
# 修改管理员密码
ADMIN_USERNAME: str = "admin"
ADMIN_PASSWORD: str = "你的强密码"
# 修改JWT密钥 (随机字符串)
SECRET_KEY: str = "随机生成一个长字符串"
# 修改外部API Token
API_TOKEN: str = "你的API密钥"
```
## 4. 启动服务
### 方式1: 直接运行 (测试)
```bash
python3 run.py
```
### 方式2: 使用 systemd (生产推荐)
创建 `/etc/systemd/system/cursorpro.service`
```ini
[Unit]
Description=CursorPro Backend
After=network.target
[Service]
Type=simple
User=root
WorkingDirectory=/opt/cursorpro
ExecStart=/usr/bin/python3 run.py
Restart=always
RestartSec=3
[Install]
WantedBy=multi-user.target
```
启动服务:
```bash
systemctl daemon-reload
systemctl enable cursorpro
systemctl start cursorpro
systemctl status cursorpro
```
### 方式3: 使用 PM2 (Node.js 环境)
```bash
pm2 start run.py --name cursorpro --interpreter python3
pm2 save
```
## 5. Nginx 反向代理 (推荐)
```nginx
server {
listen 443 ssl;
server_name api.aicode.edu.pl;
ssl_certificate /path/to/cert.pem;
ssl_certificate_key /path/to/key.pem;
location / {
proxy_pass http://127.0.0.1:8000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
```
## 6. 访问地址
- 管理后台: https://api.aicode.edu.pl/
- API文档: https://api.aicode.edu.pl/docs
- 健康检查: https://api.aicode.edu.pl/health
## 7. 数据库
默认使用 SQLite数据库文件`cursorpro.db`
如需备份,复制此文件即可。
## 8. 多域名反代配置
在其他服务器配置反代指向主后台:
```nginx
# 备用域名服务器 (api2.aicode.edu.pl)
server {
listen 443 ssl;
server_name api2.aicode.edu.pl;
ssl_certificate /path/to/cert.pem;
ssl_certificate_key /path/to/key.pem;
location / {
proxy_pass https://api.aicode.edu.pl;
proxy_set_header Host api.aicode.edu.pl;
proxy_ssl_server_name on;
}
}
```