LANCommander/LANCommander.Server/Program.cs
Pat Hartl add770b227 Refactor Settings
Settings for the server are now combined with the settings from the SDK. This introduces a large breaking change and a migration should be created. This refactor utilizes .NET Configuration and the Options pattern. This will allow for the overriding of any setting using envionment variables. It also means that Settings.yml can be used to override any .NET configuration. A SettingsProvider implementation was created, and any updating of settings was changed from SettingsService.SaveSettings() to SettingsProvider.Update(s => { ... })
2025-11-16 12:31:25 -06:00

88 lines
No EOL
1.7 KiB
C#

using Serilog;
using LANCommander.Server.UI;
using LANCommander.Server.Startup;
var builder = WebApplication.CreateBuilder(args);
if (args.Contains("--debugger"))
builder.WaitForDebugger();
builder.AddAsService();
builder.AddLogger();
builder.AddSettings();
builder.AddRazor();
builder.AddSignalR();
builder.AddCors();
builder.AddControllers();
builder.ConfigureKestrel();
builder.ConfigureAuthentication();
builder.AddIdentity();
builder.AddHangfire();
builder.AddOpenApi();
builder.AddServerProcessStatusMonitor();
builder.AddLANCommanderServices();
builder.AddDatabase(args);
builder.Services.AddHealthChecks();
Log.Debug("Building Application");
var app = builder.Build();
app.UseCors("CorsPolicy");
app.UseHttpsRedirection();
app.MapHealthChecks("/Health");
app.UseMiddlewares();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
Log.Debug("App has been run in a development environment");
app.UseMigrationsEndPoint();
}
else
{
app.UseExceptionHandler("/Home/Error");
// 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.UseHangfire();
// app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseCookiePolicy();
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
app.UseSignalR();
app.UseStaticFiles();
app.MapScalar();
app.MapEndpoints();
app.MapRazorComponents<App>()
.DisableAntiforgery()
.AddInteractiveServerRenderMode();
app.PrepareDirectories();
await app.MigrateDatabaseAsync();
await app.StartServersAsync();
await app.StartBeaconAsync();
app.GenerateThumbnails();
app.Run();
public partial class Program
{
}