Skip to content

Commit

Permalink
Use Kestrel on Windows for metrics (#6326)
Browse files Browse the repository at this point in the history
* Use Kestrel on Windows for metrics

* Add comment
  • Loading branch information
benaadams authored and kamilchodola committed Dec 8, 2023
1 parent f91bfa3 commit 7c52ffa
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/Nethermind/Nethermind.Monitoring/MonitoringService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Nethermind.Monitoring.Config;
using System.Net.Sockets;
using Prometheus;
using System.Runtime.InteropServices;

namespace Nethermind.Monitoring
{
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 7c52ffa

Please sign in to comment.