56 lines
2.5 KiB
PowerShell
56 lines
2.5 KiB
PowerShell
$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 "'", "''") + "'"
|
|
}
|