diff --git a/src/Nethermind/Nethermind.Monitoring/MonitoringService.cs b/src/Nethermind/Nethermind.Monitoring/MonitoringService.cs index edcde86d249..f7d9e87423a 100644 --- a/src/Nethermind/Nethermind.Monitoring/MonitoringService.cs +++ b/src/Nethermind/Nethermind.Monitoring/MonitoringService.cs @@ -9,6 +9,7 @@ using Nethermind.Monitoring.Config; using System.Net.Sockets; using Prometheus; +using System.Runtime.InteropServices; namespace Nethermind.Monitoring { @@ -80,8 +81,12 @@ public async Task StartAsync() } if (_exposePort is not null) { - // KestrelMetricServer intercept SIGTERM causing exitcode to be incorrect - IMetricServer metricServer = new MetricServer(_exposePort.Value); + IMetricServer metricServer = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? + // MetricServer uses HttpListener which on Windows either needs + // permissions at OS or Admin mode, whereas KestrelMetricServer doesn't need those + new KestrelMetricServer(_exposePort.Value) : + // KestrelMetricServer intercept SIGTERM causing exitcode to be incorrect + new MetricServer(_exposePort.Value); metricServer.Start(); } await Task.Factory.StartNew(() => _metricsController.StartUpdating(), TaskCreationOptions.LongRunning);