Add Windows start and update script

This commit is contained in:
mid
2026-08-08 00:06:18 +08:00
parent fa14e9e5b9
commit 023e77dbd4
3 changed files with 224 additions and 0 deletions
+37
View File
@@ -109,6 +109,43 @@ docker compose down
健康检查地址:`http://服务器地址:8080/healthz`
## Windows Server 部署(不使用 Docker)
要求安装 Git、Node.js 22.12.0 或更高版本,并使用 PowerShell 5.1 或更高版本。以下示例假设项目位于 `C:\Services\WebTools`。
首次克隆后安装依赖并构建:
```powershell
Set-Location C:\Services\WebTools
npm.cmd ci --include=dev
npm.cmd run build
```
生产构建成功后,使用项目根目录的统一脚本启动:
```powershell
powershell.exe -NoProfile -ExecutionPolicy Bypass -File .\web-tools.ps1 start
```
默认监听 `0.0.0.0:9000`,导航配置保存在 `C:\ProgramData\WebTools\data\navigation.json`。可以通过参数覆盖:
```powershell
powershell.exe -NoProfile -ExecutionPolicy Bypass -File .\web-tools.ps1 start `
-ListenAddress 127.0.0.1 `
-Port 8080 `
-DataDir C:\ProgramData\WebTools\data
```
从 Git `main` 分支更新时,先在运行窗口按 `Ctrl+C` 停止服务,再执行:
```powershell
powershell.exe -NoProfile -ExecutionPolicy Bypass -File .\web-tools.ps1 update
```
更新脚本只接受干净的 Git 工作区和当前 `main` 分支,使用 `git pull --ff-only origin main` 避免隐式合并。随后执行 `npm ci --include=dev`、生产构建并自动重新启动服务。`npm ci` 会先删除现有 `node_modules` 再按 `package-lock.json` 完整重建,不需要手工删除旧依赖。只更新和构建、不立即启动时增加 `-NoStart`。
脚本不会读取、覆盖或删除 `C:\ProgramData\WebTools\data`。PowerShell 窗口关闭后前台服务会停止;如使用 Windows 计划任务,应让任务执行 `web-tools.ps1 start`,更新时停止任务、运行 `web-tools.ps1 update -NoStart`,然后重新启动任务。
## 工具管理
管理入口不显示在页面中,直接访问: