Skip to content

Commit 1866d4e

Browse files
authored
Log when cancellation was requested
1 parent 060af42 commit 1866d4e

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

MaxPower/HostedServices/ExporterService.cs

+7-1
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,18 @@ protected override async Task ExecuteAsync(CancellationToken cancellationToken)
2424
Logger.LogInformation("Entering sleep state for {pollinterval} seconds.", MaxSettings.PollIntervalSeconds);
2525
await Task.Delay(TimeSpan.FromSeconds(MaxSettings.PollIntervalSeconds), cancellationToken);
2626
}
27+
28+
if (cancellationToken.IsCancellationRequested)
29+
Logger.LogInformation("Cancellation requested, leaving loop ...");
2730
}
2831

2932
private async Task ProcessInverter(InverterConfiguration inverter, CancellationToken cancellationToken)
3033
{
3134
if (cancellationToken.IsCancellationRequested)
35+
{
36+
Logger.LogInformation("Cancellation requested, skipping inverter {inverterId} ...", inverter.Id);
3237
return;
38+
}
3339

3440
// add an additional (generous) timeout to prevent the system from hanging if the socket conection hangs.
3541
// seems to happen sometimes after some hours of working perfectly ...
@@ -68,4 +74,4 @@ private async Task ProcessInverter(InverterConfiguration inverter, CancellationT
6874
_energyTotal.WithLabels(labels).Set(data?.EnergyTotal ?? 0);
6975
}
7076
}
71-
}
77+
}

0 commit comments

Comments
 (0)