초기 관제 시스템 뼈대 구성
This commit is contained in:
32
scripts/health-check.ps1
Normal file
32
scripts/health-check.ps1
Normal file
@@ -0,0 +1,32 @@
|
||||
param(
|
||||
[string]$BaseUrl = "http://127.0.0.1:8080",
|
||||
[string]$AdminToken = ""
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
function Invoke-CargoRadarJson {
|
||||
param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string]$Path
|
||||
)
|
||||
|
||||
$headers = @{}
|
||||
if ($AdminToken) {
|
||||
$headers["X-Admin-Token"] = $AdminToken
|
||||
}
|
||||
|
||||
Invoke-RestMethod -Uri "$BaseUrl$Path" -Method Get -Headers $headers
|
||||
}
|
||||
|
||||
$health = Invoke-CargoRadarJson -Path "/health"
|
||||
$drivers = Invoke-CargoRadarJson -Path "/api/v1/drivers"
|
||||
$latest = Invoke-CargoRadarJson -Path "/api/v1/locations/latest"
|
||||
|
||||
[pscustomobject]@{
|
||||
BaseUrl = $BaseUrl
|
||||
Health = $health.status
|
||||
ServerTime = $health.time
|
||||
DriverCount = $drivers.drivers.Count
|
||||
LatestLocationCount = $latest.locations.Count
|
||||
} | Format-List
|
||||
Reference in New Issue
Block a user