Price reminder and init approval
* Start price reminder grain * Add config and init grain at startup * Save init wallet when already init
This commit is contained in:
@@ -66,9 +66,16 @@ public static class ApiBootstrap
|
||||
.AddWorkers(configuration)
|
||||
.AddFluentValidation()
|
||||
.AddMediatR()
|
||||
.AddHostedServices()
|
||||
;
|
||||
}
|
||||
|
||||
private static IServiceCollection AddHostedServices(this IServiceCollection services)
|
||||
{
|
||||
// services.AddHostedService<PriceFetcherInitializer>();
|
||||
return services;
|
||||
}
|
||||
|
||||
// Note: IClusterClient is automatically available in co-hosting scenarios
|
||||
// through IGrainFactory. Services should inject IGrainFactory instead of IClusterClient
|
||||
// to avoid circular dependency issues during DI container construction.
|
||||
@@ -90,8 +97,8 @@ public static class ApiBootstrap
|
||||
|
||||
// Allow disabling Orleans clustering entirely in case of issues
|
||||
var disableOrleansClusteringEnv = Environment.GetEnvironmentVariable("DISABLE_ORLEANS_CLUSTERING");
|
||||
var disableOrleansClustering = !string.IsNullOrEmpty(disableOrleansClusteringEnv) &&
|
||||
bool.TryParse(disableOrleansClusteringEnv, out var disabled) && disabled;
|
||||
var disableOrleansClustering = !string.IsNullOrEmpty(disableOrleansClusteringEnv) &&
|
||||
bool.TryParse(disableOrleansClusteringEnv, out var disabled) && disabled;
|
||||
|
||||
// Get TASK_SLOT for multi-instance configuration
|
||||
var taskSlotEnv = Environment.GetEnvironmentVariable("TASK_SLOT");
|
||||
@@ -107,19 +114,19 @@ public static class ApiBootstrap
|
||||
var dashboardPort = 9999 + (taskSlot - 1); // 9999, 10000, 10001, etc.
|
||||
|
||||
// Get hostname for clustering - prioritize external IP for multi-server setups
|
||||
var hostname = Environment.GetEnvironmentVariable("CAPROVER_SERVER_IP") ?? // CapRover server IP
|
||||
Environment.GetEnvironmentVariable("EXTERNAL_IP") ?? // Custom external IP
|
||||
Environment.GetEnvironmentVariable("HOSTNAME") ?? // Container hostname
|
||||
Environment.GetEnvironmentVariable("COMPUTERNAME") ?? // Windows hostname
|
||||
"localhost";
|
||||
var hostname = Environment.GetEnvironmentVariable("CAPROVER_SERVER_IP") ?? // CapRover server IP
|
||||
Environment.GetEnvironmentVariable("EXTERNAL_IP") ?? // Custom external IP
|
||||
Environment.GetEnvironmentVariable("HOSTNAME") ?? // Container hostname
|
||||
Environment.GetEnvironmentVariable("COMPUTERNAME") ?? // Windows hostname
|
||||
"localhost";
|
||||
|
||||
// For Docker containers, always use localhost for same-server clustering
|
||||
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
|
||||
var externalIP = Environment.GetEnvironmentVariable("CAPROVER_SERVER_IP") ??
|
||||
Environment.GetEnvironmentVariable("EXTERNAL_IP");
|
||||
|
||||
var externalIP = Environment.GetEnvironmentVariable("CAPROVER_SERVER_IP") ??
|
||||
Environment.GetEnvironmentVariable("EXTERNAL_IP");
|
||||
|
||||
if (!string.IsNullOrEmpty(externalIP) && IPAddress.TryParse(externalIP, out var parsedExternalIP))
|
||||
{
|
||||
advertisedIP = parsedExternalIP;
|
||||
@@ -206,7 +213,7 @@ public static class ApiBootstrap
|
||||
options.GatewayListeningEndpoint = new IPEndPoint(IPAddress.Any, gatewayPort);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
siloBuilder
|
||||
.Configure<MessagingOptions>(options =>
|
||||
{
|
||||
@@ -221,7 +228,7 @@ public static class ApiBootstrap
|
||||
options.ProbeTimeout = TimeSpan.FromSeconds(10);
|
||||
options.IAmAliveTablePublishTimeout = TimeSpan.FromSeconds(30);
|
||||
options.MaxJoinAttemptTime = TimeSpan.FromSeconds(120);
|
||||
|
||||
|
||||
// Improved settings for development environments with stale members
|
||||
options.DefunctSiloCleanupPeriod = TimeSpan.FromMinutes(1);
|
||||
options.DefunctSiloExpiration = TimeSpan.FromMinutes(2);
|
||||
@@ -292,6 +299,11 @@ public static class ApiBootstrap
|
||||
options.Invariant = "Npgsql";
|
||||
})
|
||||
.AddAdoNetGrainStorage("platform-summary-store", options =>
|
||||
{
|
||||
options.ConnectionString = postgreSqlConnectionString;
|
||||
options.Invariant = "Npgsql";
|
||||
})
|
||||
.AddAdoNetGrainStorage("candle-store", options =>
|
||||
{
|
||||
options.ConnectionString = postgreSqlConnectionString;
|
||||
options.Invariant = "Npgsql";
|
||||
@@ -304,9 +316,14 @@ public static class ApiBootstrap
|
||||
.AddMemoryGrainStorage("bot-store")
|
||||
.AddMemoryGrainStorage("registry-store")
|
||||
.AddMemoryGrainStorage("agent-store")
|
||||
.AddMemoryGrainStorage("platform-summary-store");
|
||||
.AddMemoryGrainStorage("platform-summary-store")
|
||||
.AddMemoryGrainStorage("candle-store");
|
||||
}
|
||||
|
||||
// Configure Orleans Streams for price data distribution
|
||||
siloBuilder.AddMemoryStreams("DefaultStreamProvider")
|
||||
.AddMemoryGrainStorage("PubSubStore");
|
||||
|
||||
siloBuilder
|
||||
.ConfigureServices(services =>
|
||||
{
|
||||
@@ -316,6 +333,7 @@ public static class ApiBootstrap
|
||||
services.AddTransient<IAccountService, AccountService>();
|
||||
services.AddTransient<ITradingService, TradingService>();
|
||||
services.AddTransient<IMessengerService, MessengerService>();
|
||||
services.AddTransient<ICandleRepository, CandleRepository>();
|
||||
});
|
||||
})
|
||||
;
|
||||
@@ -347,7 +365,6 @@ public static class ApiBootstrap
|
||||
|
||||
services.AddTransient<ITradaoService, TradaoService>();
|
||||
services.AddTransient<IExchangeService, ExchangeService>();
|
||||
services.AddTransient<IExchangeStream, ExchangeStream>();
|
||||
|
||||
|
||||
services.AddTransient<IPrivyService, PrivyService>();
|
||||
@@ -357,7 +374,7 @@ public static class ApiBootstrap
|
||||
|
||||
services.AddSingleton<IMessengerService, MessengerService>();
|
||||
services.AddSingleton<IDiscordService, DiscordService>();
|
||||
|
||||
|
||||
// Admin services
|
||||
services.AddSingleton<IAdminConfigurationService, AdminConfigurationService>();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user