fix: improve llmwiki search integration
This commit is contained in:
1 parent
4809ee7db3
commit
56044d9cb7
20 files changed
+504
-66
No files matched your search
@@ -0,0 +1,55 @@
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
$RootDir = Resolve-Path (Join-Path $ScriptDir "..")
|
||||
|
||||
$BackendDir = Join-Path $RootDir "offline-backend-20260512\backend"
|
||||
$FrontendDir = Join-Path $RootDir "frontend-web"
|
||||
$RuntimeDir = Join-Path $RootDir ".runtime"
|
||||
$LogDir = Join-Path $RuntimeDir "logs"
|
||||
$PidDir = Join-Path $RuntimeDir "pids"
|
||||
|
||||
$BackendHost = if ($env:BACKEND_HOST) { $env:BACKEND_HOST } else { "0.0.0.0" }
|
||||
$BackendPort = if ($env:BACKEND_PORT) { $env:BACKEND_PORT } else { "8001" }
|
||||
$FrontendHost = if ($env:FRONTEND_HOST) { $env:FRONTEND_HOST } else { "0.0.0.0" }
|
||||
$FrontendPort = if ($env:FRONTEND_PORT) { $env:FRONTEND_PORT } else { "5174" }
|
||||
|
||||
$HostIp = if ($env:HOST_IP) { $env:HOST_IP } else { "127.0.0.1" }
|
||||
$BackendPublicBaseUrl = if ($env:BACKEND_PUBLIC_BASE_URL) { $env:BACKEND_PUBLIC_BASE_URL } else { "http://${HostIp}:${BackendPort}" }
|
||||
$FrontendPublicBaseUrl = if ($env:FRONTEND_PUBLIC_BASE_URL) { $env:FRONTEND_PUBLIC_BASE_URL } else { "http://${HostIp}:${FrontendPort}" }
|
||||
$GatewayCorsOrigins = if ($env:GATEWAY_CORS_ORIGINS) {
|
||||
$env:GATEWAY_CORS_ORIGINS
|
||||
} else {
|
||||
"http://localhost:${FrontendPort},http://127.0.0.1:${FrontendPort},http://${HostIp}:${FrontendPort},http://localhost:8080,http://127.0.0.1:8080"
|
||||
}
|
||||
|
||||
$BackendPython = Join-Path $BackendDir ".venv\Scripts\python.exe"
|
||||
$BackendVendorDir = if ($env:BACKEND_VENDOR_DIR) { $env:BACKEND_VENDOR_DIR } else { Join-Path $BackendDir ".deer-flow\python-vendor" }
|
||||
|
||||
New-Item -ItemType Directory -Force -Path $LogDir, $PidDir | Out-Null
|
||||
|
||||
function Test-PidRunning {
|
||||
param([string]$PidFile)
|
||||
if (-not (Test-Path -LiteralPath $PidFile)) { return $false }
|
||||
$rawPid = (Get-Content -LiteralPath $PidFile -ErrorAction SilentlyContinue | Select-Object -First 1)
|
||||
$processId = 0
|
||||
if (-not [int]::TryParse([string]$rawPid, [ref]$processId)) { return $false }
|
||||
return [bool](Get-Process -Id $processId -ErrorAction SilentlyContinue)
|
||||
}
|
||||
|
||||
function Stop-ProcessTree {
|
||||
param([int]$ProcessId)
|
||||
$children = Get-CimInstance Win32_Process -Filter "ParentProcessId=$ProcessId" -ErrorAction SilentlyContinue
|
||||
foreach ($child in $children) {
|
||||
Stop-ProcessTree -ProcessId ([int]$child.ProcessId)
|
||||
}
|
||||
$proc = Get-Process -Id $ProcessId -ErrorAction SilentlyContinue
|
||||
if ($proc) {
|
||||
Stop-Process -Id $ProcessId -Force -ErrorAction SilentlyContinue
|
||||
}
|
||||
}
|
||||
|
||||
function ConvertTo-PSLiteral {
|
||||
param([string]$Value)
|
||||
return "'" + ($Value -replace "'", "''") + "'"
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
. "$PSScriptRoot\env.ps1"
|
||||
|
||||
& "$PSScriptRoot\stop-all.ps1"
|
||||
& "$PSScriptRoot\start-all.ps1"
|
||||
@@ -0,0 +1,21 @@
|
||||
. "$PSScriptRoot\env.ps1"
|
||||
|
||||
& "$PSScriptRoot\start-all.ps1"
|
||||
|
||||
$deadline = (Get-Date).AddSeconds(60)
|
||||
$url = "$FrontendPublicBaseUrl/"
|
||||
Write-Host "Waiting for frontend: $url"
|
||||
|
||||
while ((Get-Date) -lt $deadline) {
|
||||
try {
|
||||
$response = Invoke-WebRequest -UseBasicParsing -Uri $url -TimeoutSec 2
|
||||
if ($response.StatusCode -ge 200 -and $response.StatusCode -lt 500) {
|
||||
Write-Host "Frontend is ready: $url"
|
||||
exit 0
|
||||
}
|
||||
} catch {
|
||||
Start-Sleep -Milliseconds 500
|
||||
}
|
||||
}
|
||||
|
||||
throw "Timed out waiting for frontend: $url"
|
||||
@@ -0,0 +1,4 @@
|
||||
. "$PSScriptRoot\env.ps1"
|
||||
|
||||
& "$PSScriptRoot\start-backend.ps1"
|
||||
& "$PSScriptRoot\start-frontend.ps1"
|
||||
@@ -0,0 +1,42 @@
|
||||
. "$PSScriptRoot\env.ps1"
|
||||
|
||||
$PidFile = Join-Path $PidDir "backend.pid"
|
||||
$LogFile = Join-Path $LogDir "backend.log"
|
||||
|
||||
if (Test-PidRunning $PidFile) {
|
||||
$existingPid = Get-Content -LiteralPath $PidFile | Select-Object -First 1
|
||||
Write-Host "Backend is already running (pid $existingPid)."
|
||||
Write-Host "URL: $BackendPublicBaseUrl"
|
||||
exit 0
|
||||
}
|
||||
|
||||
if (-not (Test-Path -LiteralPath $BackendPython)) {
|
||||
throw "Backend Python not found: $BackendPython. Run uv sync in offline-backend-20260512/backend first."
|
||||
}
|
||||
|
||||
Remove-Item -LiteralPath $PidFile -Force -ErrorAction SilentlyContinue
|
||||
New-Item -ItemType Directory -Force -Path $BackendVendorDir | Out-Null
|
||||
|
||||
Write-Host "Starting backend..."
|
||||
Write-Host "Log: $LogFile"
|
||||
|
||||
$RunnerFile = Join-Path $RuntimeDir "run-backend.ps1"
|
||||
$runner = @"
|
||||
`$ErrorActionPreference = "Continue"
|
||||
Set-Location -LiteralPath $(ConvertTo-PSLiteral $BackendDir)
|
||||
`$env:GATEWAY_CORS_ORIGINS = $(ConvertTo-PSLiteral $GatewayCorsOrigins)
|
||||
`$env:PYTHONPATH = $(ConvertTo-PSLiteral ".;$BackendVendorDir")
|
||||
if (-not `$env:WEKNORA_ADMIN_PASSWORD) { `$env:WEKNORA_ADMIN_PASSWORD = "1qaz@WSX" }
|
||||
cmd.exe /c "`"$(($BackendPython -replace '"', '\"'))`" -m uvicorn app.gateway.app:app --host $(($BackendHost -replace '"', '\"')) --port $(($BackendPort -replace '"', '\"')) --reload > `"$(($LogFile -replace '"', '\"'))`" 2>&1"
|
||||
"@
|
||||
Set-Content -LiteralPath $RunnerFile -Value $runner -Encoding UTF8
|
||||
|
||||
$proc = Start-Process -FilePath "powershell.exe" -ArgumentList @(
|
||||
"-NoProfile",
|
||||
"-ExecutionPolicy", "Bypass",
|
||||
"-File", $RunnerFile
|
||||
) -WindowStyle Hidden -PassThru
|
||||
|
||||
Set-Content -LiteralPath $PidFile -Value $proc.Id
|
||||
Write-Host "Backend started (pid $($proc.Id))."
|
||||
Write-Host "URL: $BackendPublicBaseUrl"
|
||||
@@ -0,0 +1,41 @@
|
||||
. "$PSScriptRoot\env.ps1"
|
||||
|
||||
$PidFile = Join-Path $PidDir "frontend.pid"
|
||||
$LogFile = Join-Path $LogDir "frontend.log"
|
||||
|
||||
if (Test-PidRunning $PidFile) {
|
||||
$existingPid = Get-Content -LiteralPath $PidFile | Select-Object -First 1
|
||||
Write-Host "Frontend is already running (pid $existingPid)."
|
||||
Write-Host "URL: $FrontendPublicBaseUrl"
|
||||
exit 0
|
||||
}
|
||||
|
||||
$NpmCmd = (Get-Command npm.cmd -ErrorAction SilentlyContinue).Source
|
||||
if (-not $NpmCmd) {
|
||||
throw "npm.cmd was not found in PATH. Install Node.js or add npm.cmd to PATH."
|
||||
}
|
||||
|
||||
Remove-Item -LiteralPath $PidFile -Force -ErrorAction SilentlyContinue
|
||||
|
||||
Write-Host "Starting frontend..."
|
||||
Write-Host "Log: $LogFile"
|
||||
|
||||
$RunnerFile = Join-Path $RuntimeDir "run-frontend.ps1"
|
||||
$runner = @"
|
||||
`$ErrorActionPreference = "Continue"
|
||||
Set-Location -LiteralPath $(ConvertTo-PSLiteral $FrontendDir)
|
||||
`$env:VITE_BACKEND_BASE_URL = $(ConvertTo-PSLiteral $BackendPublicBaseUrl)
|
||||
`$env:VITE_LANGGRAPH_BASE_URL = $(ConvertTo-PSLiteral "$BackendPublicBaseUrl/api")
|
||||
& $(ConvertTo-PSLiteral $NpmCmd) run dev -- --host $(ConvertTo-PSLiteral $FrontendHost) --port $(ConvertTo-PSLiteral $FrontendPort) *> $(ConvertTo-PSLiteral $LogFile)
|
||||
"@
|
||||
Set-Content -LiteralPath $RunnerFile -Value $runner -Encoding UTF8
|
||||
|
||||
$proc = Start-Process -FilePath "powershell.exe" -ArgumentList @(
|
||||
"-NoProfile",
|
||||
"-ExecutionPolicy", "Bypass",
|
||||
"-File", $RunnerFile
|
||||
) -WindowStyle Hidden -PassThru
|
||||
|
||||
Set-Content -LiteralPath $PidFile -Value $proc.Id
|
||||
Write-Host "Frontend started (pid $($proc.Id))."
|
||||
Write-Host "URL: $FrontendPublicBaseUrl"
|
||||
@@ -0,0 +1,18 @@
|
||||
. "$PSScriptRoot\env.ps1"
|
||||
|
||||
$backendPidFile = Join-Path $PidDir "backend.pid"
|
||||
$frontendPidFile = Join-Path $PidDir "frontend.pid"
|
||||
|
||||
if (Test-PidRunning $backendPidFile) {
|
||||
$pidValue = Get-Content -LiteralPath $backendPidFile | Select-Object -First 1
|
||||
Write-Host "Backend: running (pid $pidValue) $BackendPublicBaseUrl"
|
||||
} else {
|
||||
Write-Host "Backend: stopped"
|
||||
}
|
||||
|
||||
if (Test-PidRunning $frontendPidFile) {
|
||||
$pidValue = Get-Content -LiteralPath $frontendPidFile | Select-Object -First 1
|
||||
Write-Host "Frontend: running (pid $pidValue) $FrontendPublicBaseUrl"
|
||||
} else {
|
||||
Write-Host "Frontend: stopped"
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
. "$PSScriptRoot\env.ps1"
|
||||
|
||||
& "$PSScriptRoot\stop-frontend.ps1"
|
||||
& "$PSScriptRoot\stop-backend.ps1"
|
||||
@@ -0,0 +1,20 @@
|
||||
. "$PSScriptRoot\env.ps1"
|
||||
|
||||
$PidFile = Join-Path $PidDir "backend.pid"
|
||||
if (-not (Test-Path -LiteralPath $PidFile)) {
|
||||
Write-Host "Backend is not running (no pid file)."
|
||||
exit 0
|
||||
}
|
||||
|
||||
$rawPid = Get-Content -LiteralPath $PidFile | Select-Object -First 1
|
||||
$processId = 0
|
||||
if (-not [int]::TryParse([string]$rawPid, [ref]$processId) -or -not (Get-Process -Id $processId -ErrorAction SilentlyContinue)) {
|
||||
Remove-Item -LiteralPath $PidFile -Force -ErrorAction SilentlyContinue
|
||||
Write-Host "Backend is not running (stale pid file removed)."
|
||||
exit 0
|
||||
}
|
||||
|
||||
Write-Host "Stopping backend (pid $processId)..."
|
||||
Stop-ProcessTree -ProcessId $processId
|
||||
Remove-Item -LiteralPath $PidFile -Force -ErrorAction SilentlyContinue
|
||||
Write-Host "Backend stopped."
|
||||
@@ -0,0 +1,20 @@
|
||||
. "$PSScriptRoot\env.ps1"
|
||||
|
||||
$PidFile = Join-Path $PidDir "frontend.pid"
|
||||
if (-not (Test-Path -LiteralPath $PidFile)) {
|
||||
Write-Host "Frontend is not running (no pid file)."
|
||||
exit 0
|
||||
}
|
||||
|
||||
$rawPid = Get-Content -LiteralPath $PidFile | Select-Object -First 1
|
||||
$processId = 0
|
||||
if (-not [int]::TryParse([string]$rawPid, [ref]$processId) -or -not (Get-Process -Id $processId -ErrorAction SilentlyContinue)) {
|
||||
Remove-Item -LiteralPath $PidFile -Force -ErrorAction SilentlyContinue
|
||||
Write-Host "Frontend is not running (stale pid file removed)."
|
||||
exit 0
|
||||
}
|
||||
|
||||
Write-Host "Stopping frontend (pid $processId)..."
|
||||
Stop-ProcessTree -ProcessId $processId
|
||||
Remove-Item -LiteralPath $PidFile -Force -ErrorAction SilentlyContinue
|
||||
Write-Host "Frontend stopped."
|
||||
Reference in new issue
Block a user