2026-08-27 11:02:32 +08:00
|
|
|
[CmdletBinding()]
|
|
|
|
|
param([switch]$NoBuild)
|
|
|
|
|
|
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
|
$scriptDirectory = Split-Path -Parent $MyInvocation.MyCommand.Path
|
|
|
|
|
$projectRoot = Resolve-Path (Join-Path $scriptDirectory "..\..")
|
|
|
|
|
$runtimeDirectory = Join-Path $scriptDirectory "runtime"
|
|
|
|
|
$environmentFile = Join-Path $runtimeDirectory "local-rtc.env"
|
|
|
|
|
$requiredFiles = @(
|
|
|
|
|
"rtc-app-key",
|
|
|
|
|
"volc-access-key-id",
|
|
|
|
|
"volc-secret-access-key",
|
2026-08-29 21:56:51 +08:00
|
|
|
"ark-api-key",
|
2026-08-27 11:02:32 +08:00
|
|
|
"voice-chat-template.json",
|
|
|
|
|
"local-rtc.env"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
foreach ($name in $requiredFiles) {
|
|
|
|
|
if (-not (Test-Path -LiteralPath (Join-Path $runtimeDirectory $name) -PathType Leaf)) {
|
2026-08-29 21:56:51 +08:00
|
|
|
throw "Missing $name. Run .\deploy\local-rtc\configure.ps1 first."
|
2026-08-27 11:02:32 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Push-Location $projectRoot
|
|
|
|
|
try {
|
|
|
|
|
$arguments = @(
|
|
|
|
|
"compose",
|
|
|
|
|
"-f", "compose.yaml",
|
|
|
|
|
"-f", "deploy/local-rtc/compose.override.yaml",
|
|
|
|
|
"--env-file", $environmentFile,
|
|
|
|
|
"up", "-d"
|
|
|
|
|
)
|
|
|
|
|
if (-not $NoBuild) { $arguments += "--build" }
|
|
|
|
|
$arguments += @(
|
|
|
|
|
"postgres", "redis", "minio", "keycloak", "migrate", "seed",
|
|
|
|
|
"callbacks", "mock-alert-receiver", "mock-provider", "api", "worker"
|
|
|
|
|
)
|
|
|
|
|
& docker @arguments
|
2026-08-29 21:56:51 +08:00
|
|
|
if ($LASTEXITCODE -ne 0) { throw "Docker Compose startup failed." }
|
2026-08-27 11:02:32 +08:00
|
|
|
|
2026-08-29 21:56:51 +08:00
|
|
|
Write-Host "`nWaiting for local API readiness..." -ForegroundColor Cyan
|
2026-08-27 11:02:32 +08:00
|
|
|
$deadline = [DateTime]::UtcNow.AddMinutes(3)
|
|
|
|
|
do {
|
|
|
|
|
Start-Sleep -Seconds 2
|
|
|
|
|
try {
|
|
|
|
|
$health = Invoke-RestMethod -Uri "http://localhost:58080/health/ready" -TimeoutSec 3
|
|
|
|
|
if ($health) { break }
|
|
|
|
|
}
|
|
|
|
|
catch { }
|
|
|
|
|
} while ([DateTime]::UtcNow -lt $deadline)
|
|
|
|
|
|
2026-08-29 21:56:51 +08:00
|
|
|
if (-not $health) { throw "Local API did not become ready within three minutes. Check docker compose logs api worker." }
|
|
|
|
|
Write-Host "Local real RTC backend is ready: http://localhost:58080" -ForegroundColor Green
|
|
|
|
|
Write-Host "You can now start the Windows voice device simulator." -ForegroundColor Green
|
2026-08-27 11:02:32 +08:00
|
|
|
}
|
|
|
|
|
finally {
|
|
|
|
|
Pop-Location
|
|
|
|
|
}
|