Files
DP/tempdocs/部署前检查清单.md

461 lines
8.8 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.
# DesignerCEP 部署前检查清单
## ✅ 部署前准备(本地)
### 前端配置
- [ ] 创建 `Designer/.env.production` 文件
```env
VITE_API_BASE_URL=https://your-domain.com/api/v1
VITE_API_SERVER=https://your-domain.com
```
- [ ] 修改 `Designer/src/main.ts` 添加日志控制
```typescript
import { logger } from '@/utils/logger';
if (import.meta.env.PROD) {
logger.disable(); // 生产环境关闭日志
} else {
logger.enable(); // 开发环境开启日志
}
```
- [ ] 检查 `Designer/src/config.ts` 是否使用环境变量
```typescript
apiBaseUrl: import.meta.env.VITE_API_BASE_URL || 'http://127.0.0.1:8000/api/v1'
```
- [ ] 测试构建命令
```bash
cd Designer
npm run build
```
- [ ] 检查构建产物(应该在 `Designer/dist/` 目录)
- `dist/Shell/` - Shell 登录壳
- `dist/Designer/` - Core 核心应用
### 后端配置
- [ ] 创建生产环境配置文件(用于上传到服务器)
```bash
cp Server/.env.example Server/.env.production
```
- [ ] 修改 `Server/.env.production`
- [ ] 修改 `SECRET_KEY` 为强随机密钥
- [ ] 设置 `DEBUG=False`
- [ ] 配置 `ALLOWED_ORIGINS`(你的域名)
- [ ] 配置数据库连接(如使用 PostgreSQL/MySQL
- [ ] 检查 `Server/requirements.txt` 包含所有依赖
- [ ] 打包 Shell供用户下载
```bash
cd Designer/dist
zip -r shell-1.0.0.zip Shell/
# 将 shell-1.0.0.zip 准备上传到服务器
```
---
## 🖥️ 服务器准备
### 基础环境
- [ ] 服务器已购买推荐阿里云、腾讯云、AWS
- [ ] 操作系统Ubuntu 20.04+ 或 CentOS 7+
- [ ] 配置:最低 1核2G推荐 2核4G
- [ ] 已安装 Python 3.9+
```bash
python3 --version
```
- [ ] 已安装 Nginx
```bash
nginx -v
```
- [ ] 已安装 Git
```bash
git --version
```
### 域名和 SSL
- [ ] 域名已购买
- [ ] DNS 已解析到服务器 IP
```bash
# 验证 DNS 解析
ping your-domain.com
```
- [ ] 准备申请 SSL 证书Let's Encrypt 免费)
### 网络配置
- [ ] 服务器防火墙已开放端口:
- [ ] 22 (SSH)
- [ ] 80 (HTTP)
- [ ] 443 (HTTPS)
- [ ] 安全组规则已配置(云服务器)
---
## 📤 文件上传
### 上传后端代码
- [ ] 方式 1: 使用 Git推荐
```bash
ssh user@your-server
cd /var/www
git clone https://your-repo-url.git DesignerCEP
```
- [ ] 方式 2: 使用 SCP
```bash
scp -r Server/ user@your-server:/var/www/DesignerCEP/
```
### 上传前端构建产物
- [ ] 上传 Shell 在线登录页
```bash
scp -r Designer/dist/Shell/* \
user@your-server:/var/www/DesignerCEP/Server/static/shell/
```
- [ ] 上传 Core核心应用
```bash
scp -r Designer/dist/Designer/* \
user@your-server:/var/www/DesignerCEP/Server/static/core/1.0.0/
```
- [ ] 打包并上传 Shell供 CEP 扩展下载)
```bash
# 本地打包
cd Designer/dist
zip -r shell-1.0.0.zip Shell/
# 上传到服务器
scp shell-1.0.0.zip \
user@your-server:/var/www/DesignerCEP/Server/static/downloads/
```
---
## 🔧 服务器配置
### Python 环境
- [ ] 创建虚拟环境
```bash
cd /var/www/DesignerCEP/Server
python3 -m venv venv
source venv/bin/activate
```
- [ ] 安装依赖
```bash
pip install -r requirements.txt
pip install gunicorn uvicorn[standard]
```
### 环境变量
- [ ] 上传 `.env.production` 并重命名为 `.env`
```bash
scp Server/.env.production user@your-server:/var/www/DesignerCEP/Server/.env
```
- [ ] 验证配置
```bash
cat /var/www/DesignerCEP/Server/.env
```
### 目录结构
- [ ] 验证目录结构正确
```
/var/www/DesignerCEP/Server/
├── app/
├── static/
│ ├── shell/ # Shell 在线登录页
│ │ ├── index.html
│ │ └── assets/
│ ├── downloads/ # 下载文件
│ │ └── shell-1.0.0.zip
│ └── core/
│ └── 1.0.0/
│ ├── index.html
│ └── assets/
├── .env
├── requirements.txt
└── venv/
```
- [ ] 创建日志目录
```bash
mkdir -p /var/www/DesignerCEP/Server/logs
```
### Systemd 服务
- [ ] 创建服务文件
```bash
sudo nano /etc/systemd/system/designer-cep.service
```
- [ ] 启动服务
```bash
sudo systemctl daemon-reload
sudo systemctl start designer-cep
sudo systemctl enable designer-cep
```
- [ ] 验证服务状态
```bash
sudo systemctl status designer-cep
```
### Nginx 配置
- [ ] 创建 Nginx 配置文件
```bash
sudo nano /etc/nginx/sites-available/designer-cep
```
- [ ] 启用配置
```bash
sudo ln -s /etc/nginx/sites-available/designer-cep /etc/nginx/sites-enabled/
```
- [ ] 测试 Nginx 配置
```bash
sudo nginx -t
```
- [ ] 重启 Nginx
```bash
sudo systemctl restart nginx
```
### SSL 证书
- [ ] 安装 Certbot
```bash
sudo apt install certbot python3-certbot-nginx
```
- [ ] 申请证书
```bash
sudo certbot --nginx -d your-domain.com -d www.your-domain.com
```
- [ ] 验证自动续期
```bash
sudo certbot renew --dry-run
```
---
## 🧪 测试验证
### 后端 API 测试
- [ ] 健康检查
```bash
curl https://your-domain.com/api/v1/health
```
- [ ] 登录接口
```bash
curl -X POST https://your-domain.com/api/v1/client/login \
-H "Content-Type: application/json" \
-d '{"username":"test","password":"test123","device_id":"test-device"}'
```
### 前端访问测试
- [ ] 访问 Shell 在线登录页
```
https://your-domain.com/shell/
https://your-domain.com/shell/index.html
```
- [ ] 访问 Core 首页
```
https://your-domain.com/core/1.0.0/index.html
```
- [ ] 检查静态资源加载F12 查看 Network
- [ ] Shell 下载链接(供 CEP 扩展下载)
```
https://your-domain.com/downloads/shell-1.0.0.zip
```
### 功能测试
- [ ] 用户注册功能
- [ ] 用户登录功能
- [ ] 自动登录功能
- [ ] 版本检查和更新
- [ ] Photoshop 插件功能(创建图层等)
- [ ] 退出登录功能
### 性能测试
- [ ] 页面加载速度
```bash
curl -w "@curl-format.txt" -o /dev/null -s https://your-domain.com/core/1.0.0/
```
- [ ] API 响应时间
- [ ] 并发测试(可选)
```bash
ab -n 1000 -c 10 https://your-domain.com/api/v1/health
```
---
## 🔒 安全检查
- [ ] 防火墙已启用
```bash
sudo ufw status
```
- [ ] 仅开放必要端口22, 80, 443
- [ ] `SECRET_KEY` 已修改为强随机值
- [ ] `DEBUG=False` 已设置
- [ ] CORS 配置正确(`ALLOWED_ORIGINS`
- [ ] 数据库密码强度检查(如使用数据库)
- [ ] 文件权限检查
```bash
# .env 文件应该仅所有者可读
chmod 600 /var/www/DesignerCEP/Server/.env
```
- [ ] 定期更新系统和依赖
```bash
sudo apt update && sudo apt upgrade
```
---
## 📊 监控配置(可选)
- [ ] 配置日志轮转
```bash
sudo nano /etc/logrotate.d/designer-cep
```
- [ ] 设置系统监控(推荐工具)
- [ ] Prometheus + Grafana
- [ ] Zabbix
- [ ] Datadog
- [ ] 配置错误追踪(推荐)
- [ ] Sentry
- [ ] Bugsnag
- [ ] 配置服务告警(推荐)
- [ ] 邮件告警
- [ ] 短信告警
- [ ] 企业微信/钉钉告警
---
## 📝 文档和备份
- [ ] 记录服务器信息
- 服务器 IP: __________________
- SSH 用户名: __________________
- SSH 密钥位置: __________________
- 域名: __________________
- [ ] 记录部署信息
- 部署日期: __________________
- 当前版本: __________________
- 数据库位置: __________________
- [ ] 设置定期备份
- [ ] 数据库备份(每天)
- [ ] 配置文件备份
- [ ] 用户数据备份
- [ ] 编写故障恢复文档
---
## 🎉 上线后操作
- [ ] 通知用户新版本上线
- [ ] 更新 CEP 插件配置(如需要)
- 修改 API 地址指向生产环境
- [ ] 监控服务器资源使用情况
```bash
htop
df -h
```
- [ ] 检查错误日志
```bash
sudo journalctl -u designer-cep -f
sudo tail -f /var/log/nginx/designer-cep-error.log
```
- [ ] 第一周密切关注系统运行状况
---
## 🆘 应急预案
### 服务无法访问
1. 检查服务状态
```bash
sudo systemctl status designer-cep
sudo systemctl status nginx
```
2. 查看错误日志
```bash
sudo journalctl -u designer-cep -n 100 --no-pager
```
3. 重启服务
```bash
sudo systemctl restart designer-cep
sudo systemctl restart nginx
```
### 回滚到上一版本
1. 切换 Core 版本(修改后端 API 返回的版本号)
2. 或直接替换静态文件
```bash
rm -rf /var/www/DesignerCEP/Server/static/core/1.0.1
# 恢复旧版本
```
3. 重启服务
---
**检查完成日期**: _______________
**检查人**: _______________
**备注**: _______________