gongxiangp2/scripts/README.md
chenpei cd6e40d9d2 优化:网络传输性能和稳定性 - TCP缓冲区+并发控制优化
主要改动:
1. TCP缓冲区优化(16MB)- 解决公网上传速度慢问题
2. 并发数降低到1-3 - 避免4并发导致ERR_CONNECTION_RESET
3. 动态并发控制 - 根据网络环境自动调整
4. Nginx超时增加到120s - 支持大分片上传
5. 上传进度修复 - 修复剩余时间计算
6. 新增任务-页面上传器和详情组件
7. 统一部署文档为deploy-remote-build.ps1

问题修复:
- 公网用户上传从200-900KB/s提升到预期3-5MB/s
- 内网用户上传更稳定,无连接重置错误
- UploadProgress组件剩余时间计算修正

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-27 09:33:09 +08:00

130 lines
3.4 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.

# 脚本说明
## ⚠️ 重要声明
**本项目强制使用 `deploy-remote-build.ps1` 脚本进行部署**,除非项目负责人明确要求使用其他方式。
**详细说明**:[部署规范](../docs/部署规范.md)
---
## 核心部署脚本
### `deploy-remote-build.ps1` ⭐⭐⭐ **唯一推荐**
**专用构建机部署脚本** - 保护本地 SSD,提高构建效率
**文件位置**:项目根目录(`deploy-remote-build.ps1`)
**架构流程**:
```
本地电脑 → SSH 上传代码(1-5MB) → 构建机(192.168.42.134) → 构建镜像 → 推送到Registry → 生产服务器拉取 → 启动容器
```
**核心优势**:
1. 保护本地 SSD(构建在远程)
2. 构建速度快(Linux 原生)
3. 可视化管理(Registry UI: http://192.168.42.134:5001)
4. 镜像版本管理
5. 内网高速传输(1Gbps)
**使用方式:**
```powershell
# 在项目根目录执行
# 部署到正式系统(端口 4320)
.\deploy-remote-build.ps1
# 部署到影子系统(端口 5320)
.\deploy-remote-build.ps1 -Target shadow
# 跳过代码同步
.\deploy-remote-build.ps1 -SkipSync
# 跳过镜像构建
.\deploy-remote-build.ps1 -SkipBuild
# 不使用构建缓存
.\deploy-remote-build.ps1 -NoCache
# 保留旧镜像
.\deploy-remote-build.ps1 -KeepOldImages
```
**参数说明:**
- `-Target`: 部署目标,`production`(正式系统,端口4320)或 `shadow`(影子系统,端口5320)
- `-BuildServerIP`: 构建机 IP(默认:192.168.42.134)
- `-ProdServerIP`: 生产服务器 IP(默认:192.168.58.20)
- `-SkipSync`: 跳过代码同步
- `-SkipBuild`: 跳过镜像构建
- `-NoCache`: 不使用构建缓存
- `-KeepOldImages`: 保留旧镜像
---
## 🚫 其他部署方式(不推荐)
以下脚本仅作为参考,**不推荐使用**,除非项目负责人明确要求:
### `deploy-local-build.ps1` ❌
**本地构建部署** - 会在本地产生大量 Docker 缓存,磨损 SSD
**问题**:
- 本地构建占用大量磁盘空间(~2GB)
- SSD 磨损严重(频繁读写)
- 构建速度慢(Windows Docker Desktop 性能差)
- 上传镜像慢(~180MB 通过网络)
### `deploy-git-build.ps1` ⚠️
**Git 工作流部署** - 需要配置 Git 仓库,复杂度高
**问题**:
- 需要配置 Git 仓库
- 流程复杂(本地提交 → 推送 → 服务器拉取 → 构建)
- 不适合快速迭代
### `deploy-public-build.ps1` ⚠️
**公网穿透部署** - 仅在特殊情况下使用(外网访问生产环境)
**用途**:从公网访问生产环境进行部署(非常规操作)
---
**⚠️ 再次提醒**:请使用 `deploy-remote-build.ps1` 进行部署,除非项目负责人明确要求其他方式。
---
## 基础镜像管理
### `save-base-images.ps1`
下载并保存基础镜像到本地缓存
```powershell
.\save-base-images.ps1
```
### `load-base-images.ps1`
从本地加载基础镜像(部署脚本会自动调用)
```powershell
.\load-base-images.ps1
```
### `save-npm-packages.ps1`(可选)
缓存 npm 包到本地(网络不稳定时使用)
```powershell
.\save-npm-packages.ps1
```
## 数据库迁移脚本
### `execute-migration.ps1`
在生产库上执行数据库迁移(Windows PowerShell)
```powershell
.\execute-migration.ps1
```
### `execute-migration.sh`
在生产库上执行数据库迁移(Linux/Mac)
```bash
chmod +x execute-migration.sh
./execute-migration.sh
```