23 lines
689 B
PowerShell
23 lines
689 B
PowerShell
$ErrorActionPreference = "Stop"
|
|
|
|
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
|
$pidFile = Join-Path $scriptDir "metrics-ap-push.pid"
|
|
|
|
if (-not (Test-Path $pidFile)) {
|
|
Write-Host "AP metrics push 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 "AP metrics push stopped. PID: $($process.Id)"
|
|
} else {
|
|
Write-Host "AP metrics push process was already gone."
|
|
}
|
|
}
|
|
|
|
Remove-Item -LiteralPath $pidFile -Force -ErrorAction SilentlyContinue
|