Disable orleans reminder for deploy and add whitelisted addresses
This commit is contained in:
@@ -75,6 +75,19 @@ public static class ApiBootstrap
|
||||
public static IHostBuilder ConfigureOrleans(this IHostBuilder hostBuilder, IConfiguration configuration,
|
||||
bool isProduction)
|
||||
{
|
||||
// Check if Orleans grains should be active using root-level configuration
|
||||
var runOrleansGrains = configuration.GetValue<bool>("RunOrleansGrains", true);
|
||||
|
||||
// Check environment variable as override
|
||||
var runOrleansGrainsEnv = Environment.GetEnvironmentVariable("RUN_ORLEANS_GRAINS");
|
||||
|
||||
if (!string.IsNullOrEmpty(runOrleansGrainsEnv) &&
|
||||
bool.TryParse(runOrleansGrainsEnv, out var runOrleansGrainsFromEnv))
|
||||
{
|
||||
runOrleansGrains = runOrleansGrainsFromEnv;
|
||||
}
|
||||
|
||||
|
||||
var postgreSqlConnectionString = configuration.GetSection("PostgreSql")["Orleans"];
|
||||
|
||||
return hostBuilder.UseOrleans(siloBuilder =>
|
||||
@@ -85,12 +98,17 @@ public static class ApiBootstrap
|
||||
{
|
||||
options.ConnectionString = postgreSqlConnectionString;
|
||||
options.Invariant = "Npgsql";
|
||||
})
|
||||
.UseAdoNetReminderService(options =>
|
||||
});
|
||||
|
||||
// Conditionally configure reminder service based on flag
|
||||
if (runOrleansGrains)
|
||||
{
|
||||
siloBuilder.UseAdoNetReminderService(options =>
|
||||
{
|
||||
options.ConnectionString = postgreSqlConnectionString;
|
||||
options.Invariant = "Npgsql";
|
||||
});
|
||||
}
|
||||
|
||||
// Configure networking for better silo communication
|
||||
siloBuilder
|
||||
@@ -101,18 +119,33 @@ public static class ApiBootstrap
|
||||
options.ServiceId = "ManagingApp";
|
||||
options.ClusterId = configuration["ASPNETCORE_ENVIRONMENT"] ?? "Development";
|
||||
})
|
||||
.Configure<GrainCollectionOptions>(options =>
|
||||
{
|
||||
// Configure grain collection to prevent memory issues
|
||||
options.CollectionAge = TimeSpan.FromMinutes(10);
|
||||
options.CollectionQuantum = TimeSpan.FromMinutes(1);
|
||||
})
|
||||
.Configure<MessagingOptions>(options =>
|
||||
{
|
||||
// Configure messaging for better reliability
|
||||
options.ResponseTimeout = TimeSpan.FromSeconds(30);
|
||||
});
|
||||
|
||||
// Conditionally configure grain execution based on flag
|
||||
if (runOrleansGrains)
|
||||
{
|
||||
siloBuilder.Configure<GrainCollectionOptions>(options =>
|
||||
{
|
||||
// Enable grain collection for active grains
|
||||
options.CollectionAge = TimeSpan.FromMinutes(10);
|
||||
options.CollectionQuantum = TimeSpan.FromMinutes(1);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
// Disable grain execution completely
|
||||
siloBuilder.Configure<GrainCollectionOptions>(options =>
|
||||
{
|
||||
// Disable grain collection to prevent grains from running
|
||||
options.CollectionAge = TimeSpan.FromDays(365); // Very long collection age
|
||||
options.CollectionQuantum = TimeSpan.FromDays(1); // Very long quantum
|
||||
});
|
||||
}
|
||||
|
||||
siloBuilder
|
||||
.ConfigureLogging(logging => logging.SetMinimumLevel(LogLevel.Information));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user