Update logs

This commit is contained in:
2025-08-16 06:32:25 +07:00
parent 7271889bdf
commit 14f5cb0971
2 changed files with 14 additions and 15 deletions

View File

@@ -170,11 +170,8 @@ public class TradingBotBase : ITradingBot
{ {
ExecutionCount++; ExecutionCount++;
Logger.LogInformation($"Date server : {DateTime.UtcNow} - Last candle date bot : {LastCandle.Date}"); Logger.LogInformation("Bot Status - ServerDate: {ServerDate}, LastCandleDate: {LastCandleDate}, Signals: {SignalCount}, Executions: {ExecutionCount}, Positions: {PositionCount}",
Logger.LogInformation($"Signals : {Signals.Count}"); DateTime.UtcNow, LastCandle.Date, Signals.Count, ExecutionCount, Positions.Count);
Logger.LogInformation($"ExecutionCount : {ExecutionCount}");
Logger.LogInformation($"Positions : {Positions.Count}");
Logger.LogInformation("__________________________________________________");
} }
} }

View File

@@ -97,10 +97,9 @@ public static class ApiBootstrap
return hostBuilder.UseOrleans(siloBuilder => return hostBuilder.UseOrleans(siloBuilder =>
{ {
// Configure clustering - force localhost clustering in development mode // Configure clustering with improved networking or use localhost clustering if disabled
if (!disableOrleansClustering && !string.IsNullOrEmpty(postgreSqlConnectionString) && isProduction) if (!disableOrleansClustering && !string.IsNullOrEmpty(postgreSqlConnectionString))
{ {
// Only use ADO.NET clustering in production
siloBuilder siloBuilder
.UseAdoNetClustering(options => .UseAdoNetClustering(options =>
{ {
@@ -110,12 +109,12 @@ public static class ApiBootstrap
} }
else else
{ {
// Use localhost clustering for development or when database is unavailable // Fallback to localhost clustering for testing or when database is unavailable
siloBuilder.UseLocalhostClustering(); siloBuilder.UseLocalhostClustering();
} }
// Conditionally configure reminder service based on flag - only in production with ADO.NET clustering // Conditionally configure reminder service based on flag
if (runOrleansGrains && !disableOrleansClustering && !string.IsNullOrEmpty(postgreSqlConnectionString) && isProduction) if (runOrleansGrains && !disableOrleansClustering && !string.IsNullOrEmpty(postgreSqlConnectionString))
{ {
siloBuilder.UseAdoNetReminderService(options => siloBuilder.UseAdoNetReminderService(options =>
{ {
@@ -165,6 +164,10 @@ public static class ApiBootstrap
options.ProbeTimeout = TimeSpan.FromSeconds(10); options.ProbeTimeout = TimeSpan.FromSeconds(10);
options.IAmAliveTablePublishTimeout = TimeSpan.FromSeconds(30); options.IAmAliveTablePublishTimeout = TimeSpan.FromSeconds(30);
options.MaxJoinAttemptTime = TimeSpan.FromSeconds(120); options.MaxJoinAttemptTime = TimeSpan.FromSeconds(120);
// Improved settings for development environments with stale members
options.DefunctSiloCleanupPeriod = TimeSpan.FromMinutes(1);
options.DefunctSiloExpiration = TimeSpan.FromMinutes(2);
}) })
.Configure<GatewayOptions>(options => .Configure<GatewayOptions>(options =>
{ {
@@ -212,10 +215,9 @@ public static class ApiBootstrap
}); });
} }
// Configure grain storage - use ADO.NET for production or memory for development/fallback // Configure grain storage - use ADO.NET for production or memory for fallback
if (!disableOrleansClustering && !string.IsNullOrEmpty(postgreSqlConnectionString) && isProduction) if (!disableOrleansClustering && !string.IsNullOrEmpty(postgreSqlConnectionString))
{ {
// Use ADO.NET storage in production
siloBuilder siloBuilder
.AddAdoNetGrainStorage("bot-store", options => .AddAdoNetGrainStorage("bot-store", options =>
{ {
@@ -240,7 +242,7 @@ public static class ApiBootstrap
} }
else else
{ {
// Use memory storage for development or when database is unavailable // Fallback to memory storage when database is unavailable
siloBuilder siloBuilder
.AddMemoryGrainStorage("bot-store") .AddMemoryGrainStorage("bot-store")
.AddMemoryGrainStorage("registry-store") .AddMemoryGrainStorage("registry-store")