Fix orleans local

This commit is contained in:
2025-08-16 06:21:26 +07:00
parent 3dbd2e91ea
commit 7271889bdf

View File

@@ -97,9 +97,10 @@ public static class ApiBootstrap
return hostBuilder.UseOrleans(siloBuilder =>
{
// Configure clustering with improved networking or use localhost clustering if disabled
if (!disableOrleansClustering && !string.IsNullOrEmpty(postgreSqlConnectionString))
// Configure clustering - force localhost clustering in development mode
if (!disableOrleansClustering && !string.IsNullOrEmpty(postgreSqlConnectionString) && isProduction)
{
// Only use ADO.NET clustering in production
siloBuilder
.UseAdoNetClustering(options =>
{
@@ -109,12 +110,12 @@ public static class ApiBootstrap
}
else
{
// Fallback to localhost clustering for testing or when database is unavailable
// Use localhost clustering for development or when database is unavailable
siloBuilder.UseLocalhostClustering();
}
// Conditionally configure reminder service based on flag
if (runOrleansGrains && !disableOrleansClustering && !string.IsNullOrEmpty(postgreSqlConnectionString))
// Conditionally configure reminder service based on flag - only in production with ADO.NET clustering
if (runOrleansGrains && !disableOrleansClustering && !string.IsNullOrEmpty(postgreSqlConnectionString) && isProduction)
{
siloBuilder.UseAdoNetReminderService(options =>
{
@@ -131,8 +132,17 @@ public static class ApiBootstrap
}
else
{
// Use basic endpoint configuration that works reliably in Docker
siloBuilder.ConfigureEndpoints(siloPort: 11111, gatewayPort: 30000);
// Use localhost for development, proper hostname for production
if (isProduction)
{
// In production, use all interfaces
siloBuilder.ConfigureEndpoints(IPAddress.Any, 11111, 30000);
}
else
{
// In development, use localhost
siloBuilder.ConfigureEndpoints(IPAddress.Loopback, 11111, 30000);
}
}
siloBuilder
@@ -202,9 +212,10 @@ public static class ApiBootstrap
});
}
// Configure grain storage - use ADO.NET for production or memory for fallback
if (!disableOrleansClustering && !string.IsNullOrEmpty(postgreSqlConnectionString))
// Configure grain storage - use ADO.NET for production or memory for development/fallback
if (!disableOrleansClustering && !string.IsNullOrEmpty(postgreSqlConnectionString) && isProduction)
{
// Use ADO.NET storage in production
siloBuilder
.AddAdoNetGrainStorage("bot-store", options =>
{
@@ -229,7 +240,7 @@ public static class ApiBootstrap
}
else
{
// Fallback to memory storage when database is unavailable
// Use memory storage for development or when database is unavailable
siloBuilder
.AddMemoryGrainStorage("bot-store")
.AddMemoryGrainStorage("registry-store")