From 75a5daab6f2e682aefa7c1bc537e7f56d8c3800c Mon Sep 17 00:00:00 2001 From: Marius Date: Wed, 28 Jan 2026 18:33:16 +0200 Subject: [PATCH] Improve listener restart wait logic with active polling - Increase wait time from 10s to max 60s after listener restart - Add active polling every 5s to check if service is registered - Log progress while waiting for service registration - Fixes race condition where script proceeds before service is ready Co-Authored-By: Claude Opus 4.5 --- .../scripts/01-setup-database.ps1 | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/proxmox/lxc108-oracle/roa-windows-setup/scripts/01-setup-database.ps1 b/proxmox/lxc108-oracle/roa-windows-setup/scripts/01-setup-database.ps1 index 643e6c9..26928de 100644 --- a/proxmox/lxc108-oracle/roa-windows-setup/scripts/01-setup-database.ps1 +++ b/proxmox/lxc108-oracle/roa-windows-setup/scripts/01-setup-database.ps1 @@ -278,9 +278,25 @@ NAMES.DIRECTORY_PATH = (TNSNAMES, EZCONNECT) $lsnrOutput = & $lsnrctl start 2>&1 Write-LogSuccess "Listener restarted successfully" - # Wait for services to register + # Wait for services to register (can take 30-60 seconds) Write-Log "Waiting for database services to register with listener..." - Start-Sleep -Seconds 10 + $maxWait = 60 + $waited = 0 + $interval = 5 + while ($waited -lt $maxWait) { + Start-Sleep -Seconds $interval + $waited += $interval + # Check if our service is registered + $lsnrStatus = & $lsnrctl status 2>&1 | Out-String + if ($lsnrStatus -match $ServiceName) { + Write-Log "Service $ServiceName registered after ${waited}s" + break + } + Write-Log "Waiting... (${waited}s/${maxWait}s)" + } + if ($waited -ge $maxWait) { + Write-LogWarning "Service may not be fully registered yet. Continuing anyway..." + } } catch { Write-LogWarning "Could not restart listener: $_"