主要更新: - 调整并发配置为50人(数据库连接池30,Tomcat线程150,异步线程池5/20) - 实现无界阻塞队列(LinkedBlockingQueue)任务处理 - 实现分镜视频保存功能(保存到uploads目录) - 统一管理页面导航栏和右上角样式 - 添加日活用户统计功能 - 优化视频拼接和保存逻辑 - 添加部署文档和快速部署指南 - 更新.gitignore排除敏感配置文件
127 lines
2.9 KiB
Markdown
127 lines
2.9 KiB
Markdown
# 🚀 快速部署指南
|
||
|
||
本文档提供最精简的上线步骤,适合有经验的运维人员。
|
||
|
||
## 一、服务器准备(5分钟)
|
||
|
||
```bash
|
||
# 1. 安装Java 21
|
||
sudo apt update && sudo apt install -y openjdk-21-jdk
|
||
|
||
# 2. 安装MySQL 8.0
|
||
sudo apt install -y mysql-server
|
||
sudo mysql_secure_installation
|
||
|
||
# 3. 安装FFmpeg
|
||
sudo apt install -y ffmpeg
|
||
|
||
# 4. 安装Nginx
|
||
sudo apt install -y nginx
|
||
```
|
||
|
||
## 二、数据库设置(2分钟)
|
||
|
||
```sql
|
||
CREATE DATABASE aigc_platform CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||
CREATE USER 'aigc_user'@'localhost' IDENTIFIED BY '强密码';
|
||
GRANT ALL PRIVILEGES ON aigc_platform.* TO 'aigc_user'@'localhost';
|
||
FLUSH PRIVILEGES;
|
||
```
|
||
|
||
## 三、环境变量(3分钟)
|
||
|
||
创建 `/app/aigc-platform/config/.env`:
|
||
|
||
```bash
|
||
export DB_URL="jdbc:mysql://localhost:3306/aigc_platform?useUnicode=true&characterEncoding=utf8&useSSL=true&serverTimezone=Asia/Shanghai"
|
||
export DB_USERNAME="aigc_user"
|
||
export DB_PASSWORD="数据库密码"
|
||
export JWT_SECRET="$(openssl rand -base64 64)"
|
||
export AI_API_KEY="你的API密钥"
|
||
export AI_IMAGE_API_KEY="你的API密钥"
|
||
export FFMPEG_PATH="/usr/bin/ffmpeg"
|
||
export TEMP_DIR="/app/aigc-platform/temp"
|
||
export UPLOAD_PATH="/app/aigc-platform/uploads"
|
||
```
|
||
|
||
## 四、部署应用(5分钟)
|
||
|
||
```bash
|
||
# 1. 创建目录
|
||
sudo mkdir -p /app/aigc-platform/{logs,uploads,temp,config}
|
||
sudo chown -R $USER:$USER /app/aigc-platform
|
||
|
||
# 2. 上传JAR文件
|
||
scp target/demo-0.0.1-SNAPSHOT.jar user@server:/app/aigc-platform/
|
||
|
||
# 3. 创建systemd服务
|
||
sudo nano /etc/systemd/system/aigc-platform.service
|
||
```
|
||
|
||
systemd服务内容:
|
||
```ini
|
||
[Unit]
|
||
Description=AIGC Platform
|
||
After=network.target mysql.service
|
||
|
||
[Service]
|
||
Type=simple
|
||
User=your-user
|
||
WorkingDirectory=/app/aigc-platform
|
||
EnvironmentFile=/app/aigc-platform/config/.env
|
||
ExecStart=/usr/bin/java -jar -Xms1g -Xmx4g \
|
||
-Dspring.profiles.active=prod \
|
||
/app/aigc-platform/demo-0.0.1-SNAPSHOT.jar
|
||
Restart=always
|
||
|
||
[Install]
|
||
WantedBy=multi-user.target
|
||
```
|
||
|
||
```bash
|
||
# 4. 启动服务
|
||
sudo systemctl daemon-reload
|
||
sudo systemctl enable aigc-platform
|
||
sudo systemctl start aigc-platform
|
||
```
|
||
|
||
## 五、Nginx配置(3分钟)
|
||
|
||
```nginx
|
||
server {
|
||
listen 80;
|
||
server_name yourdomain.com;
|
||
|
||
location /api/ {
|
||
proxy_pass http://localhost:8080;
|
||
proxy_set_header Host $host;
|
||
proxy_set_header X-Real-IP $remote_addr;
|
||
}
|
||
|
||
location / {
|
||
root /path/to/frontend/dist;
|
||
try_files $uri $uri/ /index.html;
|
||
}
|
||
}
|
||
```
|
||
|
||
## 六、SSL证书(2分钟)
|
||
|
||
```bash
|
||
sudo apt install certbot python3-certbot-nginx
|
||
sudo certbot --nginx -d yourdomain.com
|
||
```
|
||
|
||
## ✅ 检查清单
|
||
|
||
- [ ] 应用启动成功:`sudo systemctl status aigc-platform`
|
||
- [ ] 数据库连接正常:查看日志
|
||
- [ ] API可访问:`curl http://localhost:8080/api/health`
|
||
- [ ] 前端可访问:浏览器打开域名
|
||
- [ ] SSL证书有效:`https://yourdomain.com`
|
||
|
||
**总耗时:约20分钟**
|
||
|
||
详细配置请参考 `DEPLOYMENT_CHECKLIST.md`
|
||
|