|
1 | 1 | param( |
2 | 2 | [switch]$SkipInstall, |
3 | | - [switch]$VerboseCheck |
| 3 | + [switch]$VerboseCheck, |
| 4 | + [switch]$MultiWindow |
4 | 5 | ) |
5 | 6 |
|
6 | 7 | $ErrorActionPreference = "Stop" |
@@ -82,15 +83,59 @@ function Stop-BackendProcessOnPort([int]$Port) { |
82 | 83 |
|
83 | 84 | Stop-BackendProcessOnPort -Port 5000 |
84 | 85 |
|
85 | | -Write-Host "Starting backend window..." -ForegroundColor Green |
86 | | -Write-Check "backend command: dotnet run --project $backendProject" |
87 | | -Start-Process -FilePath "powershell.exe" -WorkingDirectory $repoRoot -ArgumentList "-NoExit", "-Command", "dotnet run --project '$backendProject'" | Out-Null |
| 86 | +if (-not $MultiWindow) { |
| 87 | + Write-Host "Starting backend in current terminal mode..." -ForegroundColor Green |
| 88 | + Write-Check "backend command: dotnet run --project $backendProject" |
88 | 89 |
|
89 | | -Write-Host "Starting frontend window..." -ForegroundColor Green |
90 | | -Write-Check "frontend command: npm run -w platform-admin dev" |
91 | | -Start-Process -FilePath "powershell.exe" -WorkingDirectory $frontendDir -ArgumentList "-NoExit", "-Command", "npm run -w platform-admin dev" | Out-Null |
| 90 | + $runDir = Join-Path $repoRoot ".run" |
| 91 | + if (-not (Test-Path -LiteralPath $runDir)) { |
| 92 | + New-Item -ItemType Directory -Path $runDir | Out-Null |
| 93 | + } |
| 94 | + |
| 95 | + $backendStdOut = Join-Path $runDir "backend.out.log" |
| 96 | + $backendStdErr = Join-Path $runDir "backend.err.log" |
| 97 | + |
| 98 | + $backendProc = Start-Process -FilePath "dotnet" ` |
| 99 | + -WorkingDirectory $repoRoot ` |
| 100 | + -ArgumentList @("run", "--project", $backendProject) ` |
| 101 | + -RedirectStandardOutput $backendStdOut ` |
| 102 | + -RedirectStandardError $backendStdErr ` |
| 103 | + -PassThru |
| 104 | + |
| 105 | + Start-Sleep -Seconds 2 |
| 106 | + if ($backendProc.HasExited) { |
| 107 | + throw "Backend failed to start. Check logs: $backendStdOut / $backendStdErr" |
| 108 | + } |
| 109 | + |
| 110 | + Write-Host "Backend started (PID: $($backendProc.Id)). Logs: $backendStdOut" -ForegroundColor DarkGray |
| 111 | + Write-Host "Starting frontend in current terminal..." -ForegroundColor Green |
| 112 | + Write-Check "frontend command: npm run -w platform-admin dev" |
| 113 | + |
| 114 | + try { |
| 115 | + Set-Location -LiteralPath $frontendDir |
| 116 | + npm run -w platform-admin dev |
| 117 | + } |
| 118 | + finally { |
| 119 | + Set-Location -LiteralPath $repoRoot |
| 120 | + if (-not $backendProc.HasExited) { |
| 121 | + Write-Host "Stopping backend process (PID: $($backendProc.Id))..." -ForegroundColor Yellow |
| 122 | + Stop-Process -Id $backendProc.Id -Force |
| 123 | + } |
| 124 | + } |
| 125 | +} |
| 126 | +else { |
| 127 | + Write-Host "Starting backend window..." -ForegroundColor Green |
| 128 | + Write-Check "backend command: dotnet run --project $backendProject" |
| 129 | + Start-Process -FilePath "powershell.exe" -WorkingDirectory $repoRoot -ArgumentList "-NoExit", "-Command", "dotnet run --project '$backendProject'" | Out-Null |
| 130 | + |
| 131 | + Write-Host "Starting frontend window..." -ForegroundColor Green |
| 132 | + Write-Check "frontend command: npm run -w platform-admin dev" |
| 133 | + Start-Process -FilePath "powershell.exe" -WorkingDirectory $frontendDir -ArgumentList "-NoExit", "-Command", "npm run -w platform-admin dev" | Out-Null |
| 134 | + |
| 135 | + Write-Host "Started backend + frontend." -ForegroundColor Green |
| 136 | +} |
92 | 137 |
|
93 | | -Write-Host "Started backend + frontend." -ForegroundColor Green |
94 | 138 | Write-Host "Fast mode: & .\start.ps1 -SkipInstall" -ForegroundColor DarkGray |
| 139 | +Write-Host "Multi-window mode: & .\start.ps1 -MultiWindow" -ForegroundColor DarkGray |
95 | 140 | Write-Host "Frontend dev (no module sync): cd frontend; npm run dev:fast" -ForegroundColor DarkGray |
96 | 141 | Write-Host "Debug mode: & .\start.ps1 -VerboseCheck" -ForegroundColor DarkGray |
0 commit comments