| 12345678910111213141516171819202122232425262728293031323334353637383940 |
- # Local static JSON HTTP servers for AccountServer config fetch
- # Run in elevated PowerShell if port 80 fails
- $root = Split-Path -Parent $PSScriptRoot
- $port80Dir = Join-Path $root "local_static\port80"
- $port8000Dir = Join-Path $root "local_static\port8000"
- function Test-PortListening([int]$Port) {
- $conn = Get-NetTCPConnection -LocalPort $Port -State Listen -ErrorAction SilentlyContinue
- return $null -ne $conn
- }
- if (Test-PortListening 80) {
- Write-Host "[skip] port 80 already listening"
- } else {
- Write-Host "[start] port 80 -> $port80Dir"
- Start-Process python -ArgumentList "-m http.server 80 --directory `"$port80Dir`"" -WindowStyle Minimized
- }
- if (Test-PortListening 8000) {
- Write-Host "[skip] port 8000 already listening"
- } else {
- Write-Host "[start] port 8000 -> $port8000Dir"
- Start-Process python -ArgumentList "-m http.server 8000 --directory `"$port8000Dir`"" -WindowStyle Minimized
- }
- Start-Sleep -Seconds 2
- Write-Host ""
- Write-Host "verify:"
- foreach ($url in @(
- "http://127.0.0.1/cjw_60000_stop_server.json",
- "http://127.0.0.1:8000/serverlist.json"
- )) {
- try {
- $r = Invoke-WebRequest -Uri $url -UseBasicParsing -TimeoutSec 5
- Write-Host " OK $url HTTP $($r.StatusCode)"
- } catch {
- Write-Host " FAIL $url $($_.Exception.Message)"
- }
- }
|