31 lines
856 B
PowerShell
Executable File
31 lines
856 B
PowerShell
Executable File
Write-Host "Starting Vault dev server..."
|
|
$vaultProc = Start-Process vault `
|
|
-ArgumentList "server -dev -dev-tls" `
|
|
-RedirectStandardOutput "vault.out.log" `
|
|
-RedirectStandardError "vault.err.log" `
|
|
-WindowStyle Hidden `
|
|
-PassThru
|
|
$vaultPid = $vaultProc.Id
|
|
Write-Host "Vault started with PID $vaultPid"
|
|
Set-Content -Path vault.pid -Value $vaultPid
|
|
|
|
# Wait a moment for the job to start
|
|
Start-Sleep -Seconds 2
|
|
|
|
# Wait until Vault is ready
|
|
$maxRetries = 15
|
|
$ok = $false
|
|
for ($i=0; $i -lt $maxRetries; $i++) {
|
|
try {
|
|
Invoke-RestMethod -UseBasicParsing -SkipCertificateCheck https://127.0.0.1:8200/v1/sys/health | Out-Null
|
|
$ok = $true
|
|
break
|
|
} catch {
|
|
Start-Sleep -Seconds 2
|
|
}
|
|
}
|
|
if (-not $ok) {
|
|
Write-Error "Vault did not become ready in time"
|
|
Exit 1
|
|
}
|
|
Write-Host "Vault is up and running." |