Update silo config
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using System.Net;
|
using System.Net;
|
||||||
|
using System.Net.Sockets;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using Discord.Commands;
|
using Discord.Commands;
|
||||||
using Discord.WebSocket;
|
using Discord.WebSocket;
|
||||||
@@ -113,10 +114,33 @@ public static class ApiBootstrap
|
|||||||
Environment.GetEnvironmentVariable("COMPUTERNAME") ?? // Windows hostname
|
Environment.GetEnvironmentVariable("COMPUTERNAME") ?? // Windows hostname
|
||||||
"localhost";
|
"localhost";
|
||||||
|
|
||||||
|
// Parse the hostname to IP address for Orleans
|
||||||
|
IPAddress advertisedIP;
|
||||||
|
if (IPAddress.TryParse(hostname, out advertisedIP))
|
||||||
|
{
|
||||||
|
// hostname is already an IP address
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Try to resolve hostname to IP address
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var hostEntry = Dns.GetHostEntry(hostname);
|
||||||
|
advertisedIP = hostEntry.AddressList.FirstOrDefault(ip => ip.AddressFamily == AddressFamily.InterNetwork)
|
||||||
|
?? hostEntry.AddressList.FirstOrDefault();
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
// Fallback to localhost if resolution fails
|
||||||
|
advertisedIP = IPAddress.Loopback;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var postgreSqlConnectionString = configuration.GetSection("PostgreSql")["Orleans"];
|
var postgreSqlConnectionString = configuration.GetSection("PostgreSql")["Orleans"];
|
||||||
|
|
||||||
Console.WriteLine($"Task Slot: {taskSlot}");
|
Console.WriteLine($"Task Slot: {taskSlot}");
|
||||||
Console.WriteLine($"Hostname: {hostname}");
|
Console.WriteLine($"Hostname: {hostname}");
|
||||||
|
Console.WriteLine($"Advertised IP: {advertisedIP}");
|
||||||
Console.WriteLine($"Silo port: {siloPort}");
|
Console.WriteLine($"Silo port: {siloPort}");
|
||||||
Console.WriteLine($"Gateway port: {gatewayPort}");
|
Console.WriteLine($"Gateway port: {gatewayPort}");
|
||||||
Console.WriteLine($"Dashboard port: {dashboardPort}");
|
Console.WriteLine($"Dashboard port: {dashboardPort}");
|
||||||
@@ -132,7 +156,7 @@ public static class ApiBootstrap
|
|||||||
options.ConnectionString = postgreSqlConnectionString;
|
options.ConnectionString = postgreSqlConnectionString;
|
||||||
options.Invariant = "Npgsql";
|
options.Invariant = "Npgsql";
|
||||||
})
|
})
|
||||||
.ConfigureEndpoints(IPAddress.Any, siloPort, gatewayPort)
|
.ConfigureEndpoints(advertisedIP, siloPort, gatewayPort)
|
||||||
.Configure<ClusterOptions>(options =>
|
.Configure<ClusterOptions>(options =>
|
||||||
{
|
{
|
||||||
options.ServiceId = "ManagingApp";
|
options.ServiceId = "ManagingApp";
|
||||||
@@ -161,7 +185,7 @@ public static class ApiBootstrap
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Configure networking - use Any for Docker containerized environments
|
// Configure networking - use specific IP for Docker containerized environments
|
||||||
if (disableOrleansClustering)
|
if (disableOrleansClustering)
|
||||||
{
|
{
|
||||||
// Use localhost clustering when clustering is disabled
|
// Use localhost clustering when clustering is disabled
|
||||||
@@ -169,8 +193,8 @@ public static class ApiBootstrap
|
|||||||
}
|
}
|
||||||
else if (string.IsNullOrEmpty(postgreSqlConnectionString))
|
else if (string.IsNullOrEmpty(postgreSqlConnectionString))
|
||||||
{
|
{
|
||||||
// In Docker/containerized environments, use Any to allow inter-container communication
|
// In Docker/containerized environments, use the resolved IP address
|
||||||
siloBuilder.ConfigureEndpoints(IPAddress.Any, siloPort, gatewayPort);
|
siloBuilder.ConfigureEndpoints(advertisedIP, siloPort, gatewayPort);
|
||||||
}
|
}
|
||||||
|
|
||||||
siloBuilder
|
siloBuilder
|
||||||
|
|||||||
Reference in New Issue
Block a user