Files
story/deploy/local-rtc/start.ps1
T
2026-08-29 21:56:51 +08:00

59 lines
1.9 KiB
PowerShell

[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",
"ark-api-key",
"voice-chat-template.json",
"local-rtc.env"
)
foreach ($name in $requiredFiles) {
if (-not (Test-Path -LiteralPath (Join-Path $runtimeDirectory $name) -PathType Leaf)) {
throw "Missing $name. Run .\deploy\local-rtc\configure.ps1 first."
}
}
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
if ($LASTEXITCODE -ne 0) { throw "Docker Compose startup failed." }
Write-Host "`nWaiting for local API readiness..." -ForegroundColor Cyan
$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)
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
}
finally {
Pop-Location
}