Simplify Vault start on Windows
Some checks failed
Some checks failed
This commit is contained in:
@@ -1,55 +1,22 @@
|
||||
if (Test-Path "vault.pid") {
|
||||
$vaultPid = Get-Content "vault.pid"
|
||||
Write-Host "Stopping Vault process $vaultPid"
|
||||
Stop-Process -Id $vaultPid -Force
|
||||
Remove-Item "vault-pid" -Force
|
||||
} else {
|
||||
Write-Host "No PID file found, Vault may not have started."
|
||||
}
|
||||
|
||||
# Function to display logs
|
||||
function Show-VaultLogs {
|
||||
Write-Output "=== VAULT SERVER STDOUT (last 50 lines) ==="
|
||||
Get-Content "vault-logs/stdout.log" -ErrorAction SilentlyContinue | Select-Object -Last 50
|
||||
Write-Output "=== VAULT SERVER STDERR (last 50 lines) ==="
|
||||
Get-Content "vault-logs/stderr.log" -ErrorAction SilentlyContinue | Select-Object -Last 50
|
||||
if (Test-Path "vault.out.log") {
|
||||
Write-Output "=== VAULT SERVER STDOUT (last 25 lines) ==="
|
||||
Get-Content "vault.out.log" -ErrorAction SilentlyContinue | Select-Object -Last 25
|
||||
} else {
|
||||
Write-Output "No Vault output log found!"
|
||||
}
|
||||
|
||||
# Read PID from file (Gitea alternative to env vars)
|
||||
$vaultPid = $null
|
||||
if (Test-Path "vault-pid.txt") {
|
||||
$vaultPid = Get-Content "vault-pid.txt" -Raw
|
||||
Write-Output "✅ Found Vault PID: $vaultPid"
|
||||
if (Test-Path "vault.err.log") {
|
||||
Write-Output "=== VAULT SERVER STDERR (last 25 lines) ==="
|
||||
Get-Content "vault.err.log" -ErrorAction SilentlyContinue | Select-Object -Last 25
|
||||
} else {
|
||||
Write-Output "No Vault error log found!"
|
||||
}
|
||||
|
||||
# Check if previous steps failed
|
||||
$previousStepFailed = $false
|
||||
if ("${{ steps.start-vault.outcome }}" -eq "failure") {
|
||||
$previousStepFailed = $true
|
||||
Write-Output "❌ Vault startup step failed"
|
||||
}
|
||||
|
||||
# Stop the Vault process if we have a PID
|
||||
if ($vaultPid -and ($vaultPid -ne '')) {
|
||||
if ($previousStepFailed) {
|
||||
Write-Output "❌ Previous step failed, showing Vault logs:"
|
||||
Show-VaultLogs
|
||||
}
|
||||
|
||||
# Stop the Vault process
|
||||
try {
|
||||
Stop-Process -Id $vaultPid -Force -ErrorAction Stop
|
||||
Write-Output "✅ Stopped Vault process $vaultPid"
|
||||
} catch {
|
||||
Write-Warning "❌ Failed to stop process $vaultPid: $($_.Exception.Message)"
|
||||
}
|
||||
}
|
||||
|
||||
# Clean up any remaining Vault processes
|
||||
$vaultProcesses = Get-Process -Name "vault" -ErrorAction SilentlyContinue
|
||||
if ($vaultProcesses) {
|
||||
Write-Output "✅ Found additional Vault processes, stopping them..."
|
||||
$vaultProcesses | Stop-Process -Force -ErrorAction SilentlyContinue
|
||||
}
|
||||
|
||||
# Always show logs if we're in a failure state
|
||||
if ($previousStepFailed -or "${{ job.status }}" -eq "failure") {
|
||||
Write-Output "❌ Job failed, showing final Vault logs:"
|
||||
Show-VaultLogs
|
||||
}
|
||||
|
||||
# Cleanup PID file
|
||||
if (Test-Path "vault-pid.txt") {
|
||||
Remove-Item "vault-pid.txt" -Force
|
||||
}
|
Reference in New Issue
Block a user