Skip to content

Commit d8e87b9

Browse files
authored
Merge pull request #456 from Icinga:fix/jea_service_error_does_not_reset
Fix: JEA service error count not resetting itself While running the Icinga for Windows service in JEA context, it can happen that the corresponding WinRM service is restarted or terminated. The service daemon will keep an eye on that and restart the JEA session up to 5 times, before terminating the service and printing an error. This fix will not add a grace period, which will reset the failure counter in case the service was running for more than 3 minutes. Which is more then enough runtime to not asume a faulty service behavior.
2 parents 694c31c + 051ac45 commit d8e87b9

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

doc/100-General/10-Changelog.md

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic
3636
* [#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
3737
* [#452](https://github.com/Icinga/icinga-powershell-framework/pull/452) Fixes unhandled `true` output on the console while running the installer
3838
* [#454](https://github.com/Icinga/icinga-powershell-framework/pull/454) Fixes JEA catalog compiler and background daemon execution in JEA context
39+
* [#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
3940

4041
### Enhancements
4142

lib/daemon/Start-IcingaPowerShellDaemon.psm1

+10-1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ function Start-IcingaForWindowsDaemon()
7373

7474
if ($RunAsService) {
7575
[int]$JeaRestartCounter = 1;
76+
$FailureTime = $null;
7677
while ($TRUE) {
7778
if ([string]::IsNullOrEmpty($JeaProfile) -eq $FALSE) {
7879
if ([string]::IsNullOrEmpty($JeaPid)) {
@@ -86,14 +87,22 @@ function Start-IcingaForWindowsDaemon()
8687
}
8788

8889
Write-IcingaFileSecure -File $JeaPidFile -Value '';
90+
$FailureTime = [DateTime]::Now;
8991
Write-IcingaEventMessage -EventId 1505 -Namespace Framework -Objects ([string]::Format('{0}/5', $JeaRestartCounter));
9092
Start-IcingaForWindowsDaemon -RunAsService:$RunAsService -JEAContext:$JEAContext -JEARestart;
9193

92-
$JeaRestartCounter += 1;
94+
if (([DateTime]::Now - $FailureTime).TotalSeconds -lt 180) {
95+
$JeaRestartCounter += 1;
96+
} else {
97+
$JeaRestartCounter = 1;
98+
}
99+
93100
$JeaPid = '';
94101
}
95102

96103
Start-Sleep -Seconds 5;
104+
$JeaAliveCounter += 1;
105+
97106
continue;
98107
}
99108
Start-Sleep -Seconds 100;

0 commit comments

Comments
 (0)