Private/Stop-ApplyWatcher.ps1
|
# Internal helper -- stop the apply-watcher process + clean up its PID file. # Called from the finally block of Start-BykaCCSupervisor. function Stop-ApplyWatcher { param( [Parameter(Mandatory)][string]$WatcherPidFile, [Parameter(Mandatory)][string]$LogFile ) if (-not (Test-Path $WatcherPidFile)) { return } try { $raw = (Get-Content $WatcherPidFile -Raw -ErrorAction Stop).Trim() if ($raw -match '^\d+$') { Stop-Process -Id ([int]$raw) -Force -ErrorAction SilentlyContinue Write-LogLine -Message "Stopped apply-watcher PID=$raw on supervisor exit" -Level 'INFO' -LogFile $LogFile } } catch {} Remove-Item -LiteralPath $WatcherPidFile -ErrorAction SilentlyContinue } |