备份: 完整开发状态(含反混淆脚本和临时文件)
This commit is contained in:
123
backend/DEPLOY.md
Normal file
123
backend/DEPLOY.md
Normal file
@@ -0,0 +1,123 @@
|
||||
# 蜂鸟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;
|
||||
}
|
||||
}
|
||||
```
|
||||
Reference in New Issue
Block a user