|
| 1 | +# PowerShell script to launch Web4 demos: store, delegation manager, and trust visualizer |
| 2 | + |
| 3 | +$ErrorActionPreference = "Stop" |
| 4 | + |
| 5 | +# Ports used by the demos |
| 6 | +$ports = 8000, 8001, 8002 |
| 7 | + |
| 8 | +Write-Host "Checking for existing processes on ports: $ports" -ForegroundColor Cyan |
| 9 | + |
| 10 | +foreach ($port in $ports) { |
| 11 | + try { |
| 12 | + $conns = Get-NetTCPConnection -LocalPort $port -ErrorAction SilentlyContinue |
| 13 | + if ($conns) { |
| 14 | + foreach ($c in $conns) { |
| 15 | + Write-Host "Killing process $($c.OwningProcess) on port $port" -ForegroundColor Yellow |
| 16 | + Stop-Process -Id $c.OwningProcess -Force -ErrorAction SilentlyContinue |
| 17 | + } |
| 18 | + } |
| 19 | + } catch { |
| 20 | + Write-Host "Could not inspect port $port: $_" -ForegroundColor Red |
| 21 | + } |
| 22 | +} |
| 23 | + |
| 24 | +# Helper to start a process in a given working directory |
| 25 | +function Start-Web4Process { |
| 26 | + param( |
| 27 | + [string]$Name, |
| 28 | + [string]$WorkingDir, |
| 29 | + [string]$Arguments |
| 30 | + ) |
| 31 | + |
| 32 | + Write-Host "Starting $Name in $WorkingDir" -ForegroundColor Green |
| 33 | + Start-Process -FilePath "python" -ArgumentList $Arguments -WorkingDirectory $WorkingDir |
| 34 | +} |
| 35 | + |
| 36 | +# Resolve repo root relative to this script |
| 37 | +$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path |
| 38 | +$repoRoot = Split-Path -Parent $scriptDir |
| 39 | + |
| 40 | +# Start store (port 8000) |
| 41 | +Start-Web4Process -Name "Store" -WorkingDir (Join-Path $repoRoot "demo\store") -Arguments "app.py" |
| 42 | + |
| 43 | +# Start Delegation Manager (port 8001) |
| 44 | +Start-Web4Process -Name "Delegation Manager" -WorkingDir (Join-Path $repoRoot "demo\delegation-ui") -Arguments "app.py" |
| 45 | + |
| 46 | +# Start static server for trust visualizer (port 8002) |
| 47 | +Write-Host "Starting Trust Visualizer on http://localhost:8002" -ForegroundColor Green |
| 48 | +Start-Process -FilePath "python" -ArgumentList "-m http.server 8002" -WorkingDirectory (Join-Path $repoRoot "examples\trust-visualizer") |
| 49 | + |
| 50 | +Write-Host "\nAll services starting:" -ForegroundColor Cyan |
| 51 | +Write-Host " Store: http://localhost:8000" -ForegroundColor Cyan |
| 52 | +Write-Host " Delegation Manager: http://localhost:8001" -ForegroundColor Cyan |
| 53 | +Write-Host " Trust Visualizer: http://localhost:8002" -ForegroundColor Cyan |
0 commit comments