23 lines
698 B
PowerShell
23 lines
698 B
PowerShell
$ErrorActionPreference = "Stop"
|
|
|
|
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
|
$pidFile = Join-Path $scriptDir "metrics-http.pid"
|
|
|
|
if (-not (Test-Path $pidFile)) {
|
|
Write-Host "Metrics HTTP server is not running."
|
|
exit 0
|
|
}
|
|
|
|
$pidValue = Get-Content $pidFile -ErrorAction SilentlyContinue
|
|
if ($pidValue) {
|
|
$process = Get-Process -Id ([int]$pidValue) -ErrorAction SilentlyContinue
|
|
if ($process) {
|
|
Stop-Process -Id $process.Id -Force
|
|
Write-Host "Metrics HTTP server stopped. PID: $($process.Id)"
|
|
} else {
|
|
Write-Host "Metrics HTTP server process was already gone."
|
|
}
|
|
}
|
|
|
|
Remove-Item -LiteralPath $pidFile -Force -ErrorAction SilentlyContinue
|