Preserve agent server URL default across redeployments

This commit is contained in:
2025-10-17 03:23:18 -06:00
parent f4ced13bf5
commit 7868b3f061

View File

@@ -746,6 +746,7 @@ function InstallOrUpdate-BorealisAgent {
$agentDestinationFolder = Join-Path $venvFolderPath 'Borealis' $agentDestinationFolder = Join-Path $venvFolderPath 'Borealis'
$agentDestinationFile = Join-Path $agentDestinationFolder 'agent.py' $agentDestinationFile = Join-Path $agentDestinationFolder 'agent.py'
$venvPython = Join-Path $venvFolderPath 'Scripts\python.exe' $venvPython = Join-Path $venvFolderPath 'Scripts\python.exe'
$existingServerUrl = $null
Run-Step "Create Virtual Python Environment" { Run-Step "Create Virtual Python Environment" {
if (-not (Test-Path (Join-Path $venvFolderPath 'Scripts\Activate'))) { if (-not (Test-Path (Join-Path $venvFolderPath 'Scripts\Activate'))) {
@@ -764,6 +765,20 @@ function InstallOrUpdate-BorealisAgent {
} }
if (Test-Path $agentSourcePath) { if (Test-Path $agentSourcePath) {
# Cleanup Previous Agent Folder & Create New Folder # Cleanup Previous Agent Folder & Create New Folder
$existingServerUrlPath = Join-Path $agentDestinationFolder 'Settings\server_url.txt'
if (Test-Path $existingServerUrlPath) {
try {
$candidateUrl = (Get-Content -Path $existingServerUrlPath -ErrorAction SilentlyContinue | Select-Object -First 1)
} catch {
$candidateUrl = $null
}
if ($candidateUrl) {
$candidateUrl = $candidateUrl.Trim()
}
if ($candidateUrl) {
$existingServerUrl = $candidateUrl
}
}
Remove-Item $agentDestinationFolder -Recurse -Force -ErrorAction SilentlyContinue Remove-Item $agentDestinationFolder -Recurse -Force -ErrorAction SilentlyContinue
New-Item -Path $agentDestinationFolder -ItemType Directory -Force | Out-Null New-Item -Path $agentDestinationFolder -ItemType Directory -Force | Out-Null
@@ -831,7 +846,9 @@ function InstallOrUpdate-BorealisAgent {
} }
$defaultUrl = 'http://localhost:5000' $defaultUrl = 'http://localhost:5000'
$currentUrl = $defaultUrl $currentUrl = $defaultUrl
if (Test-Path $serverUrlPath) { if ($existingServerUrl -and $existingServerUrl.Trim()) {
$currentUrl = $existingServerUrl.Trim()
} elseif (Test-Path $serverUrlPath) {
try { $txt = (Get-Content -Path $serverUrlPath -ErrorAction SilentlyContinue | Select-Object -First 1) } catch { $txt = '' } try { $txt = (Get-Content -Path $serverUrlPath -ErrorAction SilentlyContinue | Select-Object -First 1) } catch { $txt = '' }
if ($txt -and $txt.Trim()) { $currentUrl = $txt.Trim() } if ($txt -and $txt.Trim()) { $currentUrl = $txt.Trim() }
} }