fix(windows): restore fileops collector freshness

This commit is contained in:
igor04091968
2026-05-14 15:46:03 +03:00
parent 0cce6fd08e
commit 59e93c1c69
2 changed files with 17 additions and 5 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
Set-StrictMode -Version Latest
Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'
function Assert-Administrator {
+16 -4
View File
@@ -143,9 +143,10 @@ function Flush-TransportQueue {
if (-not (Test-Path -LiteralPath $script:TransportQueuePath)) { return }
$lock = Get-TransportQueueLock
try {
$items = Read-TransportQueueItems
$script:TransportMetrics.queueDepth = $items.Count
if ($items.Count -eq 0) { return }
$items = @(Read-TransportQueueItems)
$itemCount = @($items).Count
$script:TransportMetrics.queueDepth = $itemCount
if ($itemCount -eq 0) { return }
$left = New-Object System.Collections.Generic.List[object]
$sent = 0
@@ -339,7 +340,16 @@ foreach ($path in $resolvedPaths) {
Write-FileCollectorLog "Collector started. Waiting for events..."
try {
$lastHealth = [datetime]::UtcNow.AddMinutes(-5)
try {
Send-CollectorHealthEvent
Write-FileCollectorLog "Initial collector_health heartbeat sent."
}
catch {
$script:TransportMetrics.sendFailures++
Write-FileCollectorLog ("Initial collector_health failed: {0}" -f $_.Exception.Message)
}
$lastHealth = [datetime]::UtcNow
$backoffSeconds = 1
while ($true) {
try {
@@ -355,9 +365,11 @@ try {
if ((New-TimeSpan -Start $lastHealth -End ([datetime]::UtcNow)).TotalSeconds -ge ([Math]::Max($PollSeconds * 3, 30))) {
try {
Send-CollectorHealthEvent
Write-FileCollectorLog "Periodic collector_health heartbeat sent."
}
catch {
$script:TransportMetrics.sendFailures++
Write-FileCollectorLog ("Periodic collector_health failed: {0}" -f $_.Exception.Message)
}
$lastHealth = [datetime]::UtcNow
}