fix(windows): restore fileops collector freshness
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
Set-StrictMode -Version Latest
|
Set-StrictMode -Version Latest
|
||||||
$ErrorActionPreference = 'Stop'
|
$ErrorActionPreference = 'Stop'
|
||||||
|
|
||||||
function Assert-Administrator {
|
function Assert-Administrator {
|
||||||
|
|||||||
@@ -143,9 +143,10 @@ function Flush-TransportQueue {
|
|||||||
if (-not (Test-Path -LiteralPath $script:TransportQueuePath)) { return }
|
if (-not (Test-Path -LiteralPath $script:TransportQueuePath)) { return }
|
||||||
$lock = Get-TransportQueueLock
|
$lock = Get-TransportQueueLock
|
||||||
try {
|
try {
|
||||||
$items = Read-TransportQueueItems
|
$items = @(Read-TransportQueueItems)
|
||||||
$script:TransportMetrics.queueDepth = $items.Count
|
$itemCount = @($items).Count
|
||||||
if ($items.Count -eq 0) { return }
|
$script:TransportMetrics.queueDepth = $itemCount
|
||||||
|
if ($itemCount -eq 0) { return }
|
||||||
|
|
||||||
$left = New-Object System.Collections.Generic.List[object]
|
$left = New-Object System.Collections.Generic.List[object]
|
||||||
$sent = 0
|
$sent = 0
|
||||||
@@ -339,7 +340,16 @@ foreach ($path in $resolvedPaths) {
|
|||||||
Write-FileCollectorLog "Collector started. Waiting for events..."
|
Write-FileCollectorLog "Collector started. Waiting for events..."
|
||||||
|
|
||||||
try {
|
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
|
$backoffSeconds = 1
|
||||||
while ($true) {
|
while ($true) {
|
||||||
try {
|
try {
|
||||||
@@ -355,9 +365,11 @@ try {
|
|||||||
if ((New-TimeSpan -Start $lastHealth -End ([datetime]::UtcNow)).TotalSeconds -ge ([Math]::Max($PollSeconds * 3, 30))) {
|
if ((New-TimeSpan -Start $lastHealth -End ([datetime]::UtcNow)).TotalSeconds -ge ([Math]::Max($PollSeconds * 3, 30))) {
|
||||||
try {
|
try {
|
||||||
Send-CollectorHealthEvent
|
Send-CollectorHealthEvent
|
||||||
|
Write-FileCollectorLog "Periodic collector_health heartbeat sent."
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
$script:TransportMetrics.sendFailures++
|
$script:TransportMetrics.sendFailures++
|
||||||
|
Write-FileCollectorLog ("Periodic collector_health failed: {0}" -f $_.Exception.Message)
|
||||||
}
|
}
|
||||||
$lastHealth = [datetime]::UtcNow
|
$lastHealth = [datetime]::UtcNow
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user