fix binding silo

This commit is contained in:
2025-09-07 21:47:46 +07:00
parent e455417cfc
commit 12c6aea053

View File

@@ -113,8 +113,7 @@ public static class ApiBootstrap
Environment.GetEnvironmentVariable("COMPUTERNAME") ?? // Windows hostname Environment.GetEnvironmentVariable("COMPUTERNAME") ?? // Windows hostname
"localhost"; "localhost";
// For Docker containers on the same server, use localhost binding with unique ports // For Docker containers, always use localhost for same-server clustering
IPAddress bindIP = IPAddress.Any; // Bind to all interfaces (0.0.0.0)
IPAddress advertisedIP = IPAddress.Loopback; // Advertise as localhost for same-server clustering IPAddress advertisedIP = IPAddress.Loopback; // Advertise as localhost for same-server clustering
// Only use external IP if specifically provided for multi-server scenarios // Only use external IP if specifically provided for multi-server scenarios
@@ -153,9 +152,12 @@ public static class ApiBootstrap
}) })
.Configure<EndpointOptions>(options => .Configure<EndpointOptions>(options =>
{ {
// Advertise the specific IP for clustering
options.AdvertisedIPAddress = advertisedIP; options.AdvertisedIPAddress = advertisedIP;
options.SiloPort = siloPort; options.SiloPort = siloPort;
options.GatewayPort = gatewayPort; options.GatewayPort = gatewayPort;
options.SiloListeningEndpoint = new IPEndPoint(IPAddress.Any, siloPort);
options.GatewayListeningEndpoint = new IPEndPoint(IPAddress.Any, gatewayPort);
}) })
.Configure<ClusterOptions>(options => .Configure<ClusterOptions>(options =>
{ {
@@ -193,12 +195,15 @@ public static class ApiBootstrap
} }
else if (string.IsNullOrEmpty(postgreSqlConnectionString)) else if (string.IsNullOrEmpty(postgreSqlConnectionString))
{ {
// In Docker/containerized environments, use endpoint options // In Docker/containerized environments, use endpoint configuration
siloBuilder.Configure<EndpointOptions>(options => siloBuilder.Configure<EndpointOptions>(options =>
{ {
// Advertise the specific IP for clustering
options.AdvertisedIPAddress = advertisedIP; options.AdvertisedIPAddress = advertisedIP;
options.SiloPort = siloPort; options.SiloPort = siloPort;
options.GatewayPort = gatewayPort; options.GatewayPort = gatewayPort;
options.SiloListeningEndpoint = new IPEndPoint(IPAddress.Any, siloPort);
options.GatewayListeningEndpoint = new IPEndPoint(IPAddress.Any, gatewayPort);
}); });
} }