From 051ac452b38b7717e3d9a9011463a191e5c54588 Mon Sep 17 00:00:00 2001 From: Lord Hepipud Date: Sat, 29 Jan 2022 00:23:58 +0100 Subject: [PATCH] Fixes JEA service errors not resetting themself --- doc/100-General/10-Changelog.md | 1 + lib/daemon/Start-IcingaPowerShellDaemon.psm1 | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/doc/100-General/10-Changelog.md b/doc/100-General/10-Changelog.md index 3784b7a..158798a 100644 --- a/doc/100-General/10-Changelog.md +++ b/doc/100-General/10-Changelog.md @@ -36,6 +36,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic * [#451](https://github.com/Icinga/icinga-powershell-framework/pull/451) Fixes PowerShell being unable to enter JEA context if only the Framework is installed and removes the `|` from plugin output, in case a JEA error is thrown that check commands are not present * [#452](https://github.com/Icinga/icinga-powershell-framework/pull/452) Fixes unhandled `true` output on the console while running the installer * [#454](https://github.com/Icinga/icinga-powershell-framework/pull/454) Fixes JEA catalog compiler and background daemon execution in JEA context +* [#456](https://github.com/Icinga/icinga-powershell-framework/pull/456) Fixes JEA service error count not resetting itself after a certain amount of time without errors ### Enhancements diff --git a/lib/daemon/Start-IcingaPowerShellDaemon.psm1 b/lib/daemon/Start-IcingaPowerShellDaemon.psm1 index 2e9b666..b8ee4e0 100644 --- a/lib/daemon/Start-IcingaPowerShellDaemon.psm1 +++ b/lib/daemon/Start-IcingaPowerShellDaemon.psm1 @@ -73,6 +73,7 @@ function Start-IcingaForWindowsDaemon() if ($RunAsService) { [int]$JeaRestartCounter = 1; + $FailureTime = $null; while ($TRUE) { if ([string]::IsNullOrEmpty($JeaProfile) -eq $FALSE) { if ([string]::IsNullOrEmpty($JeaPid)) { @@ -86,14 +87,22 @@ function Start-IcingaForWindowsDaemon() } Write-IcingaFileSecure -File $JeaPidFile -Value ''; + $FailureTime = [DateTime]::Now; Write-IcingaEventMessage -EventId 1505 -Namespace Framework -Objects ([string]::Format('{0}/5', $JeaRestartCounter)); Start-IcingaForWindowsDaemon -RunAsService:$RunAsService -JEAContext:$JEAContext -JEARestart; - $JeaRestartCounter += 1; + if (([DateTime]::Now - $FailureTime).TotalSeconds -lt 180) { + $JeaRestartCounter += 1; + } else { + $JeaRestartCounter = 1; + } + $JeaPid = ''; } Start-Sleep -Seconds 5; + $JeaAliveCounter += 1; + continue; } Start-Sleep -Seconds 100;