fix a bit orleans

This commit is contained in:
2025-08-16 05:23:28 +07:00
parent 6df6061d66
commit 2861a7f469
2 changed files with 22 additions and 15 deletions

View File

@@ -124,22 +124,28 @@ public static class ApiBootstrap
}
// Configure networking for better silo communication
var advertisedIP = Environment.GetEnvironmentVariable("ORLEANS_ADVERTISED_IP");
IPAddress advertisedIPAddress = null;
if (!string.IsNullOrEmpty(advertisedIP) && IPAddress.TryParse(advertisedIP, out var ipAddress))
{
advertisedIPAddress = ipAddress;
}
else if (disableOrleansClustering)
{
advertisedIPAddress = IPAddress.Loopback;
}
if (advertisedIPAddress != null)
{
siloBuilder.ConfigureEndpoints(advertisedIPAddress, 11111, 30000);
}
else
{
siloBuilder.ConfigureEndpoints(siloPort: 11111, gatewayPort: 30000);
}
siloBuilder
.ConfigureEndpoints(siloPort: 11111, gatewayPort: 30000, advertisedIP: null, listenOnAnyHostAddress: true)
.Configure<EndpointOptions>(options =>
{
// Set the advertised IP address for clustering
var advertisedIP = Environment.GetEnvironmentVariable("ORLEANS_ADVERTISED_IP");
if (!string.IsNullOrEmpty(advertisedIP) && IPAddress.TryParse(advertisedIP, out var ipAddress))
{
options.AdvertisedIPAddress = ipAddress;
}
else
{
// Fallback to localhost for single-node deployments or when clustering is disabled
options.AdvertisedIPAddress = disableOrleansClustering ? IPAddress.Loopback : IPAddress.Any;
}
})
.Configure<ClusterOptions>(options =>
{
// Configure cluster options with unique identifiers