Files
novalon-website/docs/troubleshooting/fix-plan-a-guide.md
T
张翔 7cbb7a9ac8
ci/woodpecker/push/woodpecker Pipeline failed
fix(test): 修复测试环境问题
1. jest.setup.js:
   - 添加 Request/Response/Headers 全局对象 mock
   - 解决 'Request is not defined' 错误

2. .eslintrc.json:
   - 将 jest.setup.js 添加到忽略列表

3. shared-mocks.tsx:
   - 添加 ArrowUp 图标 mock

4. back-to-top.test.tsx:
   - 重写测试使用 import 语法
   - 使用 fireEvent.scroll 触发滚动事件
   - 修复组件渲染测试
2026-03-29 14:50:09 +08:00

266 lines
4.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.
# 方案A执行指南
## 🚀 快速执行(推荐)
### 方法1: 自动化脚本(最简单)
```bash
# 1. SSH登录服务器
ssh root@139.155.109.62
# 2. 上传脚本(从本地)
# 在本地执行:
scp scripts/fix-service-restart.sh root@139.155.109.62:/tmp/
# 3. 在服务器上执行
ssh root@139.155.109.62
chmod +x /tmp/fix-service-restart.sh
/tmp/fix-service-restart.sh
```
### 方法2: 手动执行(如果脚本无法上传)
```bash
# SSH登录服务器
ssh root@139.155.109.62
# 1. 查找项目目录
find / -name "docker-compose.prod.yml" 2>/dev/null
# 或
find / -name "docker-compose.yml" 2>/dev/null
# 2. 进入项目目录(假设在/opt/novalon-website
cd /opt/novalon-website
# 3. 重启Docker容器
docker-compose -f docker-compose.prod.yml restart
# 或
docker-compose restart
# 4. 检查容器状态
docker ps
# 5. 重启Nginx
systemctl restart nginx
# 6. 检查Nginx状态
systemctl status nginx
# 7. 测试应用
curl -I http://localhost:3000
curl -I https://novalon.cn
```
## 📋 执行步骤详解
### 步骤1: 检查当前状态
```bash
# 查看Docker容器
docker ps -a
# 查看Nginx状态
systemctl status nginx
# 查看系统资源
top -bn1 | head -20
df -h
free -h
```
### 步骤2: 重启Docker容器
```bash
# 进入项目目录
cd /path/to/novalon-website
# 停止容器
docker-compose -f docker-compose.prod.yml stop
# 启动容器
docker-compose -f docker-compose.prod.yml up -d
# 等待启动
sleep 10
# 检查状态
docker ps
```
### 步骤3: 重启Nginx
```bash
# 测试配置
nginx -t
# 重启服务
systemctl restart nginx
# 检查状态
systemctl status nginx
```
### 步骤4: 验证服务
```bash
# 测试本地应用
curl -I http://localhost:3000
# 检查端口监听
netstat -tlnp | grep -E ":(3000|80|443)"
# 测试外部访问
curl -I https://novalon.cn
```
## ✅ 成功标志
执行成功后,您应该看到:
1. **Docker容器状态**
```
CONTAINER ID NAMES STATUS PORTS
xxxxx novalon-website Up 10 seconds 0.0.0.0:3000->3000/tcp
```
2. **Nginx状态**
```
Active: active (running)
```
3. **本地应用响应**
```
HTTP/1.1 200 OK
```
4. **外部访问响应**
```
HTTP/2 200
```
## ❌ 故障排查
### 如果Docker容器无法启动
```bash
# 查看容器日志
docker logs <container-name>
# 查看详细错误
docker-compose -f docker-compose.prod.yml logs
# 检查配置文件
cat docker-compose.prod.yml
# 尝试重新构建
docker-compose -f docker-compose.prod.yml build --no-cache
docker-compose -f docker-compose.prod.yml up -d
```
### 如果Nginx无法启动
```bash
# 测试配置
nginx -t
# 查看错误日志
tail -50 /var/log/nginx/error.log
# 查看系统日志
journalctl -u nginx -n 50
# 检查端口占用
netstat -tlnp | grep -E ":(80|443)"
```
### 如果应用仍然无响应
```bash
# 检查应用日志
docker logs -f <container-name>
# 检查应用进程
docker exec <container-name> ps aux
# 检查应用端口
docker exec <container-name> netstat -tlnp
# 重启应用容器
docker restart <container-name>
```
## 🔍 验证清单
执行完成后,请验证以下项目:
- [ ] Docker容器运行正常:`docker ps`
- [ ] Nginx服务运行正常:`systemctl status nginx`
- [ ] 本地应用响应正常:`curl -I http://localhost:3000`
- [ ] 端口监听正常:`netstat -tlnp | grep -E ":(3000|80|443)"`
- [ ] 外部访问正常:`curl -I https://novalon.cn`
- [ ] Git服务器正常:`git ls-remote https://git.f.novalon.cn/novalon/novalon-website.git`
- [ ] CI服务器正常:`curl -I https://ci.f.novalon.cn`
## 📊 监控命令
### 实时监控服务状态
```bash
# 监控Docker容器
watch -n 5 'docker ps'
# 监控Nginx状态
watch -n 5 'systemctl status nginx'
# 监控系统资源
watch -n 5 'free -h && df -h'
```
### 查看实时日志
```bash
# Docker容器日志
docker logs -f <container-name>
# Nginx错误日志
tail -f /var/log/nginx/error.log
# Nginx访问日志
tail -f /var/log/nginx/access.log
# 系统日志
journalctl -f
```
## 🆘 紧急情况
如果方案A无法解决问题,请:
1. **保存诊断日志**
```bash
/tmp/remote-server-diagnosis.sh --full > /tmp/diagnosis-report.log
```
2. **尝试方案B或C**
- 方案B: 清理资源并重启
- 方案C: 完全重建
3. **联系支持**
- 提供诊断日志
- 描述已尝试的步骤
- 提供服务器访问信息
## 📝 执行记录
建议记录以下信息:
```
执行时间: _______________
执行人: _______________
服务器IP: 139.155.109.62
执行结果: _______________
遇到的问题: _______________
解决方案: _______________
后续跟进: _______________
```
---
**预计执行时间**: 2-5分钟
**风险等级**: 低(仅重启服务,不修改配置)
**回滚方案**: 如有问题,可再次重启或使用其他方案