run.ps1 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. # DMS 一键构建并运行脚本
  2. # 用法:在项目根目录执行 .\build\run.ps1
  3. # 参数与 build.ps1 一致并透传(如 -SkipFrontend 跳过前端构建)
  4. [CmdletBinding()]
  5. param(
  6. [switch]$SkipFrontend,
  7. [switch]$SkipPyInstallerInstall
  8. )
  9. $ErrorActionPreference = "Stop"
  10. $ProjectRoot = Split-Path $PSScriptRoot -Parent
  11. $ReleaseDir = Join-Path $ProjectRoot "dist-package\dms-server"
  12. $ServerExe = Join-Path $ReleaseDir "dms-server.exe"
  13. Write-Host "========== DMS 一键构建并运行 ==========" -ForegroundColor Cyan
  14. Write-Host "项目根目录: $ProjectRoot"
  15. # ---------- 1. 执行构建 ----------
  16. Write-Host "`n[1/2] 执行 build.ps1..." -ForegroundColor Yellow
  17. & (Join-Path $PSScriptRoot "build.ps1") @PSBoundParameters
  18. if (-not $?) { throw "build.ps1 执行失败" }
  19. # ---------- 2. 启动服务 ----------
  20. if (-not (Test-Path $ServerExe)) {
  21. throw "未找到服务程序: $ServerExe"
  22. }
  23. Write-Host "`n[2/2] 启动 dms-server..." -ForegroundColor Yellow
  24. Write-Host "工作目录: $ReleaseDir" -ForegroundColor DarkGray
  25. Write-Host "浏览器访问: http://localhost:9345(Ctrl+C 停止服务)" -ForegroundColor DarkGray
  26. # exe 依赖工作目录定位 .env 与 dms-storage,需先进入发行目录再启动
  27. Push-Location $ReleaseDir
  28. try {
  29. & ".\dms-server.exe"
  30. } finally {
  31. Pop-Location
  32. }