feat: complete TASK-WP0-07 supervisor
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
|
||||
namespace Dada.Supervisor;
|
||||
|
||||
internal static class LoopbackPortGuard
|
||||
{
|
||||
internal static SupervisorState Check()
|
||||
{
|
||||
try
|
||||
{
|
||||
using var listener = new TcpListener(IPAddress.Parse(LoopbackEndpoint.Host), LoopbackEndpoint.Port);
|
||||
listener.Start();
|
||||
return SupervisorState.Starting;
|
||||
}
|
||||
catch (SocketException)
|
||||
{
|
||||
return SupervisorState.PortInUse;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user