Files
aiagent/_start_api.ps1

20 lines
816 B
PowerShell
Raw Normal View History

$env:PYTHONPATH = 'D:\aaa\aiagent\backend'
$proc = Start-Process -FilePath 'D:\aaa\aiagent\backend\venv\Scripts\python.exe' `
-ArgumentList '-m', 'uvicorn', 'app.main:app', '--host', '0.0.0.0', '--port', '8037' `
-WorkingDirectory 'D:\aaa\aiagent\backend' `
-WindowStyle Hidden `
-RedirectStandardOutput 'D:\aaa\aiagent\logs\api_stdout.log' `
-RedirectStandardError 'D:\aaa\aiagent\logs\api_stderr.log' `
-PassThru
Write-Host "API PID: $($proc.Id)"
Start-Sleep -Seconds 5
$listening = netstat -ano | Select-String ":8037.*LISTENING"
if ($listening) {
Write-Host "SUCCESS: API is listening on port 8037"
} else {
Write-Host "WARNING: API not yet listening, checking stderr..."
if (Test-Path 'D:\aaa\aiagent\logs\api_stderr.log') {
Get-Content 'D:\aaa\aiagent\logs\api_stderr.log' -Tail 10
}
}