mirror of
https://github.com/bunny-lab-io/Borealis.git
synced 2025-10-26 17:41:58 -06:00
Preserve agent server URL default across redeployments
This commit is contained in:
19
Borealis.ps1
19
Borealis.ps1
@@ -746,6 +746,7 @@ function InstallOrUpdate-BorealisAgent {
|
||||
$agentDestinationFolder = Join-Path $venvFolderPath 'Borealis'
|
||||
$agentDestinationFile = Join-Path $agentDestinationFolder 'agent.py'
|
||||
$venvPython = Join-Path $venvFolderPath 'Scripts\python.exe'
|
||||
$existingServerUrl = $null
|
||||
|
||||
Run-Step "Create Virtual Python Environment" {
|
||||
if (-not (Test-Path (Join-Path $venvFolderPath 'Scripts\Activate'))) {
|
||||
@@ -764,6 +765,20 @@ function InstallOrUpdate-BorealisAgent {
|
||||
}
|
||||
if (Test-Path $agentSourcePath) {
|
||||
# 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
|
||||
New-Item -Path $agentDestinationFolder -ItemType Directory -Force | Out-Null
|
||||
|
||||
@@ -831,7 +846,9 @@ function InstallOrUpdate-BorealisAgent {
|
||||
}
|
||||
$defaultUrl = 'http://localhost:5000'
|
||||
$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 = '' }
|
||||
if ($txt -and $txt.Trim()) { $currentUrl = $txt.Trim() }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user