59 lines
2.2 KiB
PowerShell
59 lines
2.2 KiB
PowerShell
# Church SongLyric - Remote Health Check Script
|
|
# Usage: .\health-check.ps1 [url]
|
|
# Example: .\health-check.ps1 http://yourhost.noip.org:5000
|
|
|
|
param(
|
|
[string]$Url = "http://localhost:5000"
|
|
)
|
|
|
|
$separator = "=" * 60
|
|
Write-Host $separator -ForegroundColor Cyan
|
|
Write-Host "Church SongLyric - Health Check" -ForegroundColor Green
|
|
Write-Host $separator -ForegroundColor Cyan
|
|
Write-Host ""
|
|
|
|
$healthUrl = "$Url/api/health"
|
|
$pingUrl = "$Url/api/ping"
|
|
$rootUrl = "$Url/"
|
|
|
|
Write-Host "[1/3] Testing Root Endpoint..." -ForegroundColor Yellow
|
|
try {
|
|
$response = Invoke-RestMethod -Uri $rootUrl -TimeoutSec 5 -ErrorAction Stop
|
|
Write-Host " [OK] Success" -ForegroundColor Green
|
|
Write-Host " Message: $($response.message)" -ForegroundColor Gray
|
|
Write-Host " Port: $($response.port)" -ForegroundColor Gray
|
|
} catch {
|
|
Write-Host " [FAIL] Failed: $($_.Exception.Message)" -ForegroundColor Red
|
|
}
|
|
|
|
Write-Host ""
|
|
Write-Host "[2/3] Testing Health Endpoint..." -ForegroundColor Yellow
|
|
try {
|
|
$response = Invoke-RestMethod -Uri $healthUrl -TimeoutSec 5 -ErrorAction Stop
|
|
Write-Host " [OK] Success" -ForegroundColor Green
|
|
Write-Host " Status: $($response.status)" -ForegroundColor Gray
|
|
Write-Host " Timestamp: $($response.ts)" -ForegroundColor Gray
|
|
if ($response.uptime_ms) {
|
|
$uptimeSeconds = [math]::Round($response.uptime_ms / 1000, 2)
|
|
Write-Host " Uptime: ${uptimeSeconds}s" -ForegroundColor Gray
|
|
}
|
|
} catch {
|
|
Write-Host " [FAIL] Failed: $($_.Exception.Message)" -ForegroundColor Red
|
|
}
|
|
|
|
Write-Host ""
|
|
Write-Host "[3/3] Testing Ping Endpoint..." -ForegroundColor Yellow
|
|
try {
|
|
$response = Invoke-RestMethod -Uri $pingUrl -TimeoutSec 5 -ErrorAction Stop
|
|
Write-Host " [OK] Success" -ForegroundColor Green
|
|
Write-Host " Pong: $($response.pong)" -ForegroundColor Gray
|
|
Write-Host " Timestamp: $($response.ts)" -ForegroundColor Gray
|
|
} catch {
|
|
Write-Host " [FAIL] Failed: $($_.Exception.Message)" -ForegroundColor Red
|
|
}
|
|
|
|
Write-Host ""
|
|
Write-Host $separator -ForegroundColor Cyan
|
|
Write-Host "Health check complete!" -ForegroundColor Green
|
|
Write-Host $separator -ForegroundColor Cyan
|