Files
monisuo/DEPLOY_INSTRUCTIONS.md

408 lines
6.6 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.
# 🚀 生产环境部署指南
**项目**: Monisuo 虚拟货币模拟交易系统
**版本**: v1.0
**日期**: 2026-03-23
---
## 📋 部署前检查清单
- ✅ 前端构建完成Flutter Web + Vue3
- ✅ 后端代码已提交
- ✅ 数据库补丁已执行
- ✅ Git 已推送到远程仓库
---
## 🔧 部署步骤
### **Step 1: SSH 登录服务器**
```bash
ssh root@8.155.172.147
```
### **Step 2: 进入项目目录**
```bash
cd /path/to/monisuo
# 或者
cd /root/monisuo
```
### **Step 3: 拉取最新代码**
```bash
# 查看当前状态
git status
# 拉取最新代码
git pull origin main
# 查看最新提交
git log --oneline -5
```
**预期输出**:
```
9269f70 build: 构建前端生产版本
ca34261 docs: 添加最终测试总结报告
5c8df49 fix: 完善资金充值/提现逻辑
c294f66 fix: 添加冷钱包表支持,修复充值功能
```
---
### **Step 4: 重启后端服务**
#### **方式A: 使用 systemd**
```bash
# 重启服务
systemctl restart monisuo
# 查看状态
systemctl status monisuo
# 查看日志
journalctl -u monisuo -f
```
#### **方式B: 使用脚本**
```bash
# 停止旧服务
pkill -f monisuo-1.0.jar
# 启动新服务
nohup java -jar target/monisuo-1.0.jar --server.port=5010 > /var/log/monisuo/app.log 2>&1 &
# 查看日志
tail -f /var/log/monisuo/app.log
```
#### **方式C: 使用 Docker**
```bash
# 重新构建镜像
docker build -t monisuo:latest .
# 重启容器
docker-compose restart monisuo-backend
# 查看日志
docker-compose logs -f monisuo-backend
```
---
### **Step 5: 部署前端**
#### **Flutter Web**
```bash
# 复制构建产物到 Web 服务器目录
cp -r flutter_monisuo/build/web/* /var/www/monisuo-web/
# 设置权限
chown -R www-data:www-data /var/www/monisuo-web/
chmod -R 755 /var/www/monisuo-web/
```
#### **Vue3 管理后台**
```bash
# 复制构建产物到 Web 服务器目录
cp -r monisuo-admin/dist/* /var/www/monisuo-admin/
# 设置权限
chown -R www-data:www-data /var/www/monisuo-admin/
chmod -R 755 /var/www/monisuo-admin/
```
---
### **Step 6: 配置 Nginx**
#### **前端配置**
```nginx
# /etc/nginx/sites-available/monisuo-web
server {
listen 80;
server_name your-domain.com;
root /var/www/monisuo-web;
index index.html;
location / {
try_files $uri $uri/ /index.html;
}
# API 代理
location /api/ {
proxy_pass http://localhost:5010;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}
```
#### **管理后台配置**
```nginx
# /etc/nginx/sites-available/monisuo-admin
server {
listen 80;
server_name admin.your-domain.com;
root /var/www/monisuo-admin;
index index.html;
location / {
try_files $uri $uri/ /index.html;
}
# API 代理
location /admin/ {
proxy_pass http://localhost:5010;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}
```
#### **重启 Nginx**
```bash
# 测试配置
nginx -t
# 重启服务
systemctl restart nginx
# 查看状态
systemctl status nginx
```
---
### **Step 7: 验证部署**
#### **1. 检查后端服务**
```bash
# 健康检查
curl http://localhost:5010/health
# 测试钱包接口
curl http://localhost:5010/api/wallet/default
# 预期返回
{
"code": "0000",
"msg": "成功",
"data": {
"id": 1,
"name": "USDT-TRC20 主钱包",
"address": "TRX1234567890abcdefghijklmnopqrstuvwxyz1234",
"network": "TRC20"
},
"success": true
}
```
#### **2. 检查前端访问**
```bash
# 用户端
curl http://localhost/
# 管理后台
curl http://localhost/admin/
```
#### **3. 运行完整测试**
```bash
# 进入项目目录
cd /root/monisuo
# 运行测试脚本
./test_fund_flow.sh
```
---
## 🧪 功能测试
### **充值流程测试**
1. **用户端操作**
- 访问用户端前端
- 登录账户
- 进入"资产"页面
- 点击"充值"按钮
- 输入充值金额(如 100 USDT
- 确认充值
- 查看钱包地址
- 点击"已打款"
2. **管理后台操作**
- 登录管理后台
- 进入"订单管理"页面
- 查看待审批订单
- 点击"审批通过"或"审批驳回"
- 填写备注(如驳回需填写原因)
3. **验证结果**
- 用户端查看订单状态
- 查看资金账户余额变化
### **提现流程测试**
1. **用户端操作**
- 进入"资产"页面
- 点击"提现"按钮
- 输入提现金额(如 50 USDT
- 输入提现地址
- 输入联系方式
- 确认提现
2. **管理后台操作**
- 查看待审批提现订单
- 点击"确认打款"或"驳回"
- 填写备注
3. **验证结果**
- 用户端查看订单状态
- 查看资金账户余额变化
---
## 🐛 常见问题排查
### **问题1: 后端服务无法启动**
```bash
# 检查端口占用
netstat -tunlp | grep 5010
# 检查日志
tail -f /var/log/monisuo/app.log
# 检查 Java 版本
java -version
```
### **问题2: 前端页面无法访问**
```bash
# 检查 Nginx 状态
systemctl status nginx
# 检查文件权限
ls -la /var/www/monisuo-web/
# 检查 Nginx 配置
nginx -t
```
### **问题3: 数据库连接失败**
```bash
# 检查数据库连接
mysql -u monisuo -p -h 8.155.172.147 monisuo
# 检查数据库表
SHOW TABLES;
SELECT * FROM cold_wallet;
```
### **问题4: 充值/提现功能异常**
```bash
# 检查数据库数据
SELECT * FROM cold_wallet WHERE is_default=1 AND status=1;
# 检查订单数据
SELECT * FROM order_fund ORDER BY create_time DESC LIMIT 5;
# 检查用户资金账户
SELECT * FROM account_fund WHERE user_id=1;
```
---
## 📊 监控和日志
### **后端日志**
```bash
# 实时日志
tail -f /var/log/monisuo/app.log
# 历史日志
cat /var/log/monisuo/app.log | grep ERROR
```
### **Nginx 日志**
```bash
# 访问日志
tail -f /var/log/nginx/access.log
# 错误日志
tail -f /var/log/nginx/error.log
```
### **系统监控**
```bash
# CPU 和内存
top
# 磁盘空间
df -h
# 网络连接
netstat -tunlp
```
---
## ✅ 部署完成检查
- [ ] 后端服务运行正常
- [ ] 前端页面访问正常
- [ ] 充值流程测试通过
- [ ] 提现流程测试通过
- [ ] 管理后台功能正常
- [ ] 日志记录正常
- [ ] 监控配置完成
---
## 📞 技术支持
如遇问题,请检查:
1. **日志文件**
- 后端: `/var/log/monisuo/app.log`
- Nginx: `/var/log/nginx/error.log`
2. **配置文件**
- 后端: `application-prod.yml`
- Nginx: `/etc/nginx/sites-available/monisuo-*`
3. **测试脚本**
- 充值测试: `./test_deposit_api.sh`
- 完整测试: `./test_fund_flow.sh`
---
**部署指南版本**: v1.0
**最后更新**: 2026-03-23 22:00
**状态**: ✅ 准备就绪