42 lines
1.4 KiB
PowerShell
42 lines
1.4 KiB
PowerShell
|
|
$ErrorActionPreference = "SilentlyContinue"
|
||
|
|
$backend = "D:\aaa\aiagent\backend"
|
||
|
|
|
||
|
|
Get-CimInstance Win32_Process | Where-Object {
|
||
|
|
$_.CommandLine -and $_.CommandLine -match "celery" -and $_.CommandLine -match "celery_app"
|
||
|
|
} | ForEach-Object {
|
||
|
|
Write-Host "Stop Celery PID $($_.ProcessId)"
|
||
|
|
Stop-Process -Id $_.ProcessId -Force
|
||
|
|
}
|
||
|
|
|
||
|
|
Get-CimInstance Win32_Process | Where-Object {
|
||
|
|
$_.CommandLine -and $_.CommandLine -match "uvicorn" -and $_.CommandLine -match "app.main:app"
|
||
|
|
} | ForEach-Object {
|
||
|
|
Write-Host "Stop Uvicorn PID $($_.ProcessId)"
|
||
|
|
Stop-Process -Id $_.ProcessId -Force
|
||
|
|
}
|
||
|
|
|
||
|
|
Start-Sleep -Seconds 2
|
||
|
|
|
||
|
|
$py = Join-Path $backend "venv\Scripts\python.exe"
|
||
|
|
Write-Host "Start Uvicorn :8037 ..."
|
||
|
|
Start-Process -FilePath $py -ArgumentList @(
|
||
|
|
"-m", "uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8037", "--reload"
|
||
|
|
) -WorkingDirectory $backend -WindowStyle Minimized
|
||
|
|
|
||
|
|
Start-Sleep -Seconds 2
|
||
|
|
|
||
|
|
Write-Host "Start Celery worker ..."
|
||
|
|
Start-Process -FilePath $py -ArgumentList @(
|
||
|
|
"-m", "celery", "-A", "app.core.celery_app", "worker",
|
||
|
|
"--loglevel=info", "--pool=threads", "--concurrency=8"
|
||
|
|
) -WorkingDirectory $backend -WindowStyle Minimized
|
||
|
|
|
||
|
|
Start-Sleep -Seconds 3
|
||
|
|
try {
|
||
|
|
$r = Invoke-WebRequest -Uri "http://127.0.0.1:8037/health" -UseBasicParsing -TimeoutSec 15
|
||
|
|
Write-Host "health: $($r.Content)"
|
||
|
|
} catch {
|
||
|
|
Write-Host "health check failed: $($_.Exception.Message)"
|
||
|
|
}
|
||
|
|
Write-Host "Done."
|