- Aggiunto TradeHistoryService per persistenza trade/posizioni attive su disco (JSON, auto-save/restore) - Logging centralizzato (LoggingService) con livelli, categorie, simbolo e buffer circolare (500 log) - Nuova pagina Logs: monitoraggio real-time, filtri avanzati, cancellazione log, colorazione livelli - Sezione "Dati Persistenti" in Settings: conteggio trade, dimensione dati, reset con conferma modale - Background service per salvataggio sicuro su shutdown/stop container - Aggiornata sidebar, stili modali/bottoni danger, .gitignore e documentazione (README, CHANGELOG, UNRAID_INSTALL, checklist) - Versione 1.3.0
59 lines
1.6 KiB
C#
59 lines
1.6 KiB
C#
using TradingBot.Components;
|
|
using TradingBot.Services;
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
// Configure Kestrel - Solo in Development usa porte da launchSettings
|
|
// In Production/Docker usa porta 8080 su tutte le interfacce
|
|
if (builder.Environment.IsProduction() || builder.Environment.EnvironmentName == "Docker")
|
|
{
|
|
builder.WebHost.ConfigureKestrel(serverOptions =>
|
|
{
|
|
serverOptions.ListenAnyIP(8080);
|
|
});
|
|
}
|
|
|
|
// Add services to the container.
|
|
builder.Services.AddRazorComponents()
|
|
.AddInteractiveServerComponents();
|
|
|
|
// Trading Bot Services - Using Simulated Market Data
|
|
builder.Services.AddSingleton<IMarketDataService, SimulatedMarketDataService>();
|
|
builder.Services.AddSingleton<ITradingStrategy, SimpleMovingAverageStrategy>();
|
|
builder.Services.AddSingleton<TradeHistoryService>();
|
|
builder.Services.AddSingleton<LoggingService>();
|
|
builder.Services.AddSingleton<TradingBotService>();
|
|
builder.Services.AddSingleton<SettingsService>();
|
|
|
|
// Register background service for graceful shutdown
|
|
builder.Services.AddHostedService<TradingBotBackgroundService>();
|
|
|
|
// Add health checks for Docker
|
|
builder.Services.AddHealthChecks();
|
|
|
|
var app = builder.Build();
|
|
|
|
// Configure the HTTP request pipeline.
|
|
if (!app.Environment.IsDevelopment())
|
|
{
|
|
app.UseExceptionHandler("/Error", createScopeForErrors: true);
|
|
app.UseHsts();
|
|
}
|
|
|
|
// HTTPS redirect solo in Development
|
|
if (app.Environment.IsDevelopment())
|
|
{
|
|
app.UseHttpsRedirection();
|
|
}
|
|
|
|
app.UseStaticFiles();
|
|
app.UseAntiforgery();
|
|
|
|
// Health check endpoint
|
|
app.MapHealthChecks("/health");
|
|
|
|
app.MapRazorComponents<App>()
|
|
.AddInteractiveServerRenderMode();
|
|
|
|
app.Run();
|