54 lines
1.6 KiB
C#
54 lines
1.6 KiB
C#
using MP.Data.Services;
|
|
using MP.MON8.Components;
|
|
using NLog;
|
|
using NLog.Web;
|
|
using StackExchange.Redis;
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
// Add services to the container.
|
|
builder.Services.AddRazorComponents()
|
|
.AddInteractiveServerComponents();
|
|
|
|
var logger = LogManager.Setup()
|
|
.LoadConfigurationFromAppSettings()
|
|
.GetCurrentClassLogger();
|
|
logger.Info("Program.cs: startup");
|
|
|
|
ConfigurationManager configuration = builder.Configuration;
|
|
|
|
// REDIS setup
|
|
logger.Info("Setup REDIS");
|
|
string connStringRedis = configuration.GetConnectionString("Redis") ?? "localhost:6379";
|
|
string redisSrvAddr = connStringRedis.Substring(0, connStringRedis.IndexOf(":"));
|
|
// avvio oggetto shared x redis...
|
|
var redisMultiplexer = ConnectionMultiplexer.Connect(connStringRedis);
|
|
|
|
// Add services to the container.
|
|
logger.Info("Setup Services");
|
|
builder.Services.AddRazorPages();
|
|
builder.Services.AddServerSideBlazor();
|
|
builder.Services.AddSingleton<IConnectionMultiplexer>(redisMultiplexer);
|
|
builder.Services.AddSingleton<MonDataFeeder>();
|
|
|
|
var app = builder.Build();
|
|
|
|
// Configure the HTTP request pipeline.
|
|
if (!app.Environment.IsDevelopment())
|
|
{
|
|
app.UseExceptionHandler("/Error", createScopeForErrors: true);
|
|
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
|
|
app.UseHsts();
|
|
}
|
|
|
|
app.UseHttpsRedirection();
|
|
|
|
app.UseStaticFiles();
|
|
app.UseAntiforgery();
|
|
|
|
app.MapRazorComponents<App>()
|
|
.AddInteractiveServerRenderMode();
|
|
|
|
logger.Info("App: Run stage");
|
|
app.Run();
|