diff --git a/deploy_engine_windows.ps1 b/deploy_engine_windows.ps1 new file mode 100644 index 0000000..63b9483 --- /dev/null +++ b/deploy_engine_windows.ps1 @@ -0,0 +1,68 @@ +# deploy_engine_windows.ps1 - REBUILD + DEPLOY daw_engine.exe (PyInstaller onedir) +# Chay TREN may Windows 192.168.1.24 (source clone tai C:\Users\locpham\SonicForgeStudio): +# powershell -ExecutionPolicy Bypass -File deploy_engine_windows.ps1 +# Lam gi: git pull code moi -> build.mjs (frontend) -> pyinstaller engine.spec +# (backend fix vao exe) -> detect noi engine dang chay -> copy bundle moi vao do +# -> kill + restart engine. LUU Y: chi dung ky tu ASCII (PowerShell 5.1 doc ANSI). +$ErrorActionPreference = "Stop" +Set-Location $PSScriptRoot + +Write-Host "== [0/6] Pull code moi (fix MASTERING PANEL VST FX) ==" +git pull --ff-only +if ($LASTEXITCODE -ne 0) { Write-Host "git pull LOI - kiem tra network/credential" -ForegroundColor Red; exit 1 } + +Write-Host "== [1/6] Frontend bundle (app.jsx -> app.precompiled.js) ==" +if (-not (Test-Path "node_modules\@babel\standalone")) { + npm install @babel/standalone --no-audit --no-fund +} +node build.mjs +if ($LASTEXITCODE -ne 0) { Write-Host "build.mjs LOI" -ForegroundColor Red; exit 1 } + +Write-Host "== [2/6] Rebuild daw_engine.exe (PyInstaller, backend fix vao PYZ) ==" +pyinstaller engine.spec --clean --noconfirm +if ($LASTEXITCODE -ne 0) { Write-Host "pyinstaller LOI" -ForegroundColor Red; exit 1 } + +Write-Host "== [3/6] Verify bundle ==" +python tools\verify_bundle.py +if ($LASTEXITCODE -ne 0) { Write-Host "Bundle thieu asset - dung deploy" -ForegroundColor Red; exit 1 } + +Write-Host "== [4/6] Detect noi engine dang chay ==" +$proc = Get-Process -Name "daw_engine" -ErrorAction SilentlyContinue | Select-Object -First 1 +$runDir = $null +if ($proc) { + $runDir = Split-Path $proc.Path -Parent + Write-Host "Engine dang chay tai: $runDir (PID $($proc.Id))" +} else { + $cand = @( + "C:\Users\locpham\SonicForgeStudio\install\daw_engine", + "C:\Users\locpham\SonicForgeStudio\dist\daw_engine" + ) + foreach ($c in $cand) { + if (Test-Path (Join-Path $c "daw_engine.exe")) { $runDir = $c; break } + } + if (-not $runDir) { Write-Host "Khong tim thay noi chua daw_engine.exe" -ForegroundColor Red; exit 1 } + Write-Host "Engine chua chay - se deploy vao: $runDir" +} + +Write-Host "== [5/6] Kill engine cu + copy bundle moi ==" +if ($proc) { + Stop-Process -Name "daw_engine" -Force -ErrorAction SilentlyContinue + Start-Sleep -Seconds 2 +} +Copy-Item "dist\daw_engine\*" $runDir -Recurse -Force +Write-Host "Da copy bundle moi vao $runDir" + +Write-Host "== [6/6] Restart engine ==" +$exe = Join-Path $runDir "daw_engine.exe" +Start-Process $exe -WorkingDirectory $runDir +Start-Sleep -Seconds 6 + +Write-Host "" +Write-Host "== XAC MINH ==" +try { + $r = Invoke-WebRequest -Uri "http://localhost:8000/" -UseBasicParsing -TimeoutSec 10 + Write-Host "HTTP $($r.StatusCode) - engine da chay lai OK" -ForegroundColor Green +} catch { + Write-Host "Chua thay engine tren port 8000 (co the dang chay port 8001-8010 hoac Tauri shell chua spawn)" -ForegroundColor Yellow +} +Write-Host "Hard refresh trinh duyet (Ctrl+Shift+R) -> Plugin Manager -> Scan -> MASTERING PANEL -> VST FX phai hien thi."