Try fixing orleans server runtime
This commit is contained in:
@@ -287,4 +287,6 @@ app.UseEndpoints(endpoints =>
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
app.Run();
|
app.Run();
|
||||||
@@ -409,7 +409,7 @@ public class LiveTradingBotGrain : Grain<TradingBotGrainState>, ITradingBotGrain
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (_tradingBot == null || State.Status != BotStatus.Up)
|
if (_tradingBot == null || State.Status != BotStatus.Up || _isDisposed)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -422,6 +422,12 @@ public class LiveTradingBotGrain : Grain<TradingBotGrainState>, ITradingBotGrain
|
|||||||
|
|
||||||
await SaveBackupToState();
|
await SaveBackupToState();
|
||||||
}
|
}
|
||||||
|
catch (ObjectDisposedException)
|
||||||
|
{
|
||||||
|
// Gracefully handle disposed service provider during shutdown
|
||||||
|
_logger.LogInformation("Service provider disposed during shutdown for LiveTradingBotGrain {GrainId}", this.GetPrimaryKey());
|
||||||
|
return;
|
||||||
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogError(ex, "Error during bot execution cycle for LiveTradingBotGrain {GrainId}", this.GetPrimaryKey());
|
_logger.LogError(ex, "Error during bot execution cycle for LiveTradingBotGrain {GrainId}", this.GetPrimaryKey());
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ using Microsoft.Extensions.DependencyInjection;
|
|||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
|
using Orleans.Configuration;
|
||||||
|
|
||||||
namespace Managing.Bootstrap;
|
namespace Managing.Bootstrap;
|
||||||
|
|
||||||
@@ -100,9 +101,22 @@ public static class ApiBootstrap
|
|||||||
}
|
}
|
||||||
|
|
||||||
siloBuilder
|
siloBuilder
|
||||||
.ConfigureLogging(logging => logging.SetMinimumLevel(LogLevel.Information))
|
.ConfigureLogging(logging => logging.SetMinimumLevel(LogLevel.Information));
|
||||||
.UseDashboard(options => { })
|
|
||||||
.AddMemoryGrainStorageAsDefault()
|
// Only enable dashboard in development to avoid shutdown issues
|
||||||
|
if (!isProduction)
|
||||||
|
{
|
||||||
|
siloBuilder.UseDashboard(options =>
|
||||||
|
{
|
||||||
|
// Configure dashboard with proper shutdown handling
|
||||||
|
options.Port = 8080;
|
||||||
|
options.HostSelf = true;
|
||||||
|
options.CounterUpdateIntervalMs = 10000; // 10 seconds
|
||||||
|
options.HideTrace = true; // Hide trace to reduce dashboard overhead
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
siloBuilder.AddMemoryGrainStorageAsDefault()
|
||||||
.ConfigureServices(services =>
|
.ConfigureServices(services =>
|
||||||
{
|
{
|
||||||
// Register existing services for Orleans DI
|
// Register existing services for Orleans DI
|
||||||
@@ -112,6 +126,12 @@ public static class ApiBootstrap
|
|||||||
services.AddTransient<ITradingService, TradingService>();
|
services.AddTransient<ITradingService, TradingService>();
|
||||||
services.AddTransient<IMessengerService, MessengerService>();
|
services.AddTransient<IMessengerService, MessengerService>();
|
||||||
services.AddTransient<IBackupBotService, BackupBotService>();
|
services.AddTransient<IBackupBotService, BackupBotService>();
|
||||||
|
})
|
||||||
|
.Configure<ClusterOptions>(options =>
|
||||||
|
{
|
||||||
|
// Configure cluster options
|
||||||
|
options.ServiceId = "ManagingApp";
|
||||||
|
options.ClusterId = configuration["ASPNETCORE_ENVIRONMENT"] ?? "Development";
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
;
|
;
|
||||||
|
|||||||
Reference in New Issue
Block a user