feat(日志): 实现定时日志清理功能并统一服务端口为19070

- 添加每小时定时清理项目控制台日志功能,保留最新1000条且不超过24小时
- 将所有服务端口统一调整为19070,包括后端API、Nginx配置和文档
- 优化前端日志显示,支持单行折叠和点击展开
- 更新相关测试用例和部署文档
This commit is contained in:
2026-01-22 14:06:44 +08:00
parent 4551ae5733
commit 240e708fbe
21 changed files with 472 additions and 211 deletions

View File

@@ -6,8 +6,8 @@
**检查日期**: 2026-01-16
**部署架构**: NginxDocker容器+ Express后端systemd管理
**前端访问地址**: blv-rd.tech:20100
**后端API地址**: http://127.0.0.1:19910
**前端访问地址**: blv-rd.tech:19199
**后端API地址**: http://127.0.0.1:19070
## 二、配置文件清单
@@ -21,7 +21,7 @@
```nginx
server {
listen 20001;
listen 19199;
server_name blv-rd.tech;
root /var/www/bls_project_console;
@@ -30,7 +30,7 @@ server {
client_max_body_size 100M;
location /api/ {
proxy_pass http://host.docker.internal:3001;
proxy_pass http://host.docker.internal:19070;
proxy_http_version 1.1;
proxy_set_header Host $host;
@@ -54,10 +54,10 @@ server {
**检查项**:
- ✅ 监听端口: 20100(正确)
- ✅ 监听端口: 19199(正确)
- ✅ 服务器名称: blv-rd.tech正确
- ✅ 静态文件根目录: /var/www/bls_project_console正确
- ✅ API代理地址: http://host.docker.internal:19910正确Nginx在Docker容器中
- ✅ API代理地址: http://host.docker.internal:19070正确Nginx在Docker容器中
- ✅ 文件上传大小限制: 100M正确
- ✅ Vue Router history模式支持: try_files $uri $uri/ /index.html正确
- ✅ 超时设置: 连接60s、发送60s、读取300s正确
@@ -93,7 +93,7 @@ RestartSec=10
StandardOutput=append:/vol1/1000/Docker/nginx/project/bls/bls_project_console/backend/logs/systemd-out.log
StandardError=append:/vol1/1000/Docker/nginx/project/bls/bls_project_console/backend/logs/systemd-err.log
Environment=NODE_ENV=production
Environment=PORT=3001
Environment=PORT=19070
[Install]
WantedBy=multi-user.target
@@ -109,7 +109,7 @@ WantedBy=multi-user.target
- ✅ 重启策略: on-failure正确
- ✅ 重启延迟: 10秒合理
- ✅ 日志输出: 标准输出和错误日志分离(正确)
- ✅ 环境变量: NODE_ENV=production, PORT=19910正确
- ✅ 环境变量: NODE_ENV=production, PORT=19070正确
- ✅ 开机自启: WantedBy=multi-user.target正确
**说明**:
@@ -129,7 +129,7 @@ WantedBy=multi-user.target
**关键配置**:
```javascript
const PORT = 19910;
const PORT = parsePort(process.env.PORT, 19070);
app.use(cors());
app.use(express.json());
@@ -145,7 +145,7 @@ app.get('/api/health', (req, res) => {
**检查项**:
- ✅ 端口配置: 19910与systemd配置一致
- ✅ 端口配置: 19070与systemd配置一致
- ✅ CORS中间件: 已启用(正确)
- ✅ JSON解析: 已启用(正确)
- ✅ API路由: /api/logs, /api/commands, /api/projects正确
@@ -155,7 +155,7 @@ app.get('/api/health', (req, res) => {
**说明**:
- 端口19910与systemd服务配置中的PORT环境变量一致
- 端口19070与systemd服务配置中的PORT环境变量一致
- 提供健康检查端点便于监控
- 支持优雅关闭确保Redis连接正确关闭
@@ -181,7 +181,7 @@ export default defineConfig({
port: 3000,
proxy: {
'/api': {
target: 'http://localhost:3001',
target: 'http://localhost:19070',
changeOrigin: true,
},
},
@@ -200,7 +200,7 @@ export default defineConfig({
- ✅ 源码根目录: src/frontend正确
- ✅ 输出目录: ../../dist正确
- ✅ 开发服务器端口: 3000正确
- ✅ API代理: /api -> http://localhost:3001(正确,仅用于开发环境)
- ✅ API代理: /api -> http://localhost:19070(正确,仅用于开发环境)
- ✅ 路径别名: @ -> src/frontend正确
**说明**:
@@ -270,10 +270,10 @@ app.mount('#app');
| 配置项 | 端口 | 状态 |
| -------------------------- | ----- | --------------- |
| 后端服务器 (server.js) | 19910 | ✅ |
| Systemd服务 (PORT环境变量) | 19910 | ✅ |
| Nginx代理目标 | 19910 | ✅ |
| Nginx监听端口 | 20100 | ✅ |
| 后端服务器 (server.js) | 19070 | ✅ |
| Systemd服务 (PORT环境变量) | 19070 | ✅ |
| Nginx代理目标 | 19070 | ✅ |
| Nginx监听端口 | 19199 | ✅ |
| Vite开发服务器 | 3000 | ✅ (仅开发环境) |
### 路径配置一致性
@@ -303,7 +303,7 @@ app.mount('#app');
2. ✅ 上传dist文件夹内容到: /vol1/1000/Docker/nginx/project/bls/bls_project_console
3. ✅ 上传Nginx配置到: /vol1/1000/Docker/nginx/conf.d/bls_project_console.conf
4. ✅ 重启Nginx容器: `docker restart nginx`
5. ✅ 访问地址: http://blv-rd.tech:20100
5. ✅ 访问地址: http://blv-rd.tech:19199
### 后端部署流程
@@ -321,7 +321,7 @@ app.mount('#app');
### 1. Nginx容器网络配置
**问题**: Nginx容器需要能够访问宿主机的3001端口
**问题**: Nginx容器需要能够访问宿主机的19070端口
**建议**:
@@ -386,8 +386,8 @@ npm --version
redis-cli ping
# 4. 检查端口占用
netstat -tlnp | grep 3001
netstat -tlnp | grep 20001
netstat -tlnp | grep 19070
netstat -tlnp | grep 19199
```
### 部署后验证
@@ -397,16 +397,16 @@ netstat -tlnp | grep 20001
systemctl status bls-project-console.service
# 2. 检查后端服务
curl http://localhost:3001/api/health
curl http://localhost:19070/api/health
# 3. 检查Nginx容器
docker ps | grep nginx
# 4. 检查前端访问
curl http://blv-rd.tech:20001
curl http://blv-rd.tech:19199
# 5. 检查API代理
curl http://blv-rd.tech:20001/api/health
curl http://blv-rd.tech:19199/api/health
```
---