Skip to content

Commit 964556a

Browse files
author
Sergey Kuznetsov
committed
fix HttpListener
1 parent eb1c24c commit 964556a

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/Prometheus.Client.MetricServer/MetricServer.HttpListener.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System.IO;
77
using System.Text;
88
using System.Diagnostics;
9+
using System.Threading;
910

1011
namespace Prometheus.Client.MetricServer
1112
{
@@ -14,6 +15,7 @@ namespace Prometheus.Client.MetricServer
1415
/// </summary>
1516
public class MetricServer : BaseMetricServer, IMetricServer
1617
{
18+
private Thread _bgThread;
1719
private readonly HttpListener _httpListener = new HttpListener();
1820
private bool _isListening = false;
1921

@@ -53,6 +55,16 @@ public MetricServer(string hostname, int port, string url, IEnumerable<IOnDemand
5355

5456
/// <inheritdoc />
5557
public void Start()
58+
{
59+
_bgThread = new Thread(new ThreadStart(StartListen))
60+
{
61+
IsBackground = true,
62+
Name = "MetricsServer"
63+
};
64+
_bgThread.Start();
65+
}
66+
67+
private void StartListen()
5668
{
5769
_httpListener.Start();
5870
_isListening = true;
@@ -98,6 +110,7 @@ public void Stop()
98110
_isListening = false;
99111
_httpListener.Stop();
100112
_httpListener.Close();
113+
101114
}
102115
}
103116
}

src/Prometheus.Client.MetricServer/Prometheus.Client.MetricServer.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<Description>MetricServer for the Prometheus.Client</Description>
55
<Copyright>2017 © Sergey Kuznetsov</Copyright>
66
<AssemblyTitle>Prometheus.Client.MetricServer</AssemblyTitle>
7-
<VersionPrefix>1.1.1</VersionPrefix>
7+
<VersionPrefix>1.1.2</VersionPrefix>
88
<Authors>Sergey Kuznetsov</Authors>
99
<TargetFrameworks>net45;netstandard1.3</TargetFrameworks>
1010
<AssemblyName>Prometheus.Client.MetricServer</AssemblyName>

0 commit comments

Comments
 (0)