diff --git a/script/vault-start.ps1 b/script/vault-start.ps1 index f1b9e15..ccacdd1 100755 --- a/script/vault-start.ps1 +++ b/script/vault-start.ps1 @@ -16,10 +16,23 @@ $vaultArgs = @( ) Write-Output "✅ Starting Vault server..." -$process = Start-Process -FilePath "cmd.exe" -ArgumentList "/c start `"Vault Server`" /B .\vault.exe $vaultArgs" - +$vaultJob = Start-Job -Name "VaultServer" -ScriptBlock { + param($Args) + & ".\vault.exe" $Args +} -ArgumentList $vaultArgs -$vaultPid = $process.Id -Write-Output "✅ Vault process started with PID: $vaultPid" +# Wait a moment for the job to start +Start-Sleep -Seconds 2 + +# Get the actual process ID from the job +$vaultProcess = Get-Process -Name "vault" -ErrorAction SilentlyContinue | Select-Object -First 1 +if ($vaultProcess) { + $vaultProcess.Id | Out-File -FilePath "vault-pid.txt" + Write-Output "✅ Vault process started with PID: $($vaultProcess.Id)" +} else { + Write-Output "❌ Could not find Vault process" + exit 1 +} # Wait for Vault to become ready using port check $timeout = 30 @@ -28,7 +41,6 @@ $isReady = $false $vaultPort = 8200 Write-Output "🕐 Waiting for Vault to start on port $vaultPort..." - while ($counter -lt $timeout) { # Check if process is still running if (-not (Get-Process -Id $vaultPid -ErrorAction SilentlyContinue)) {