LANCommander/LANCommander.Server/Program.cs

93 lines
1.9 KiB
C#
Raw Normal View History

2025-02-08 15:28:13 -06:00
using LANCommander.Server.UI;
using LANCommander.Server.Startup;
var builder = WebApplication.CreateBuilder(args);
2025-02-08 15:28:13 -06:00
if (args.Contains("--debugger"))
2025-03-11 21:21:16 -05:00
builder.WaitForDebugger();
2025-02-08 15:28:13 -06:00
builder.AddSettings();
2025-02-08 15:28:13 -06:00
builder.AddAsService();
builder.AddLogger();
2025-03-11 21:21:16 -05:00
builder.AddRazor();
builder.AddSignalR();
builder.AddCors();
builder.AddControllers();
2025-02-08 15:28:13 -06:00
builder.ConfigureKestrel();
builder.ConfigureAuthentication();
builder.AddIdentity();
builder.AddHangfire();
2025-02-09 01:23:33 -06:00
builder.AddOpenApi();
builder.AddServerProcessStatusMonitor();
builder.AddLANCommanderServices();
2025-12-13 00:27:54 -06:00
builder.AddMigrations();
builder.AddDatabase(args);
builder.UseSteam();
builder.Services.AddHealthChecks();
var app = builder.Build();
2025-12-11 15:26:27 +11:00
var logger = app.Services.GetRequiredService<ILogger<Program>>();
logger.LogDebug("Building Application");
2025-11-17 20:31:11 -06:00
app.UseDatabase(args);
app.ValidateSettings();
app.UseCors("CorsPolicy");
2025-02-08 15:28:13 -06:00
app.UseHttpsRedirection();
app.MapHealthChecks("/Health");
2025-03-11 21:21:16 -05:00
app.UseMiddlewares();
2025-02-08 15:28:13 -06:00
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
2025-12-11 15:26:27 +11:00
logger.LogDebug("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();
}
2025-03-11 21:21:16 -05:00
app.UseHangfire();
// app.UseHttpsRedirection();
app.UseStaticFiles();
2025-02-08 15:28:13 -06:00
app.UseCookiePolicy();
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
2025-03-11 21:21:16 -05:00
app.UseSignalR();
2025-02-08 15:28:13 -06:00
app.UseStaticFiles();
app.MapScalar();
2025-03-11 21:21:16 -05:00
app.MapEndpoints();
2025-02-16 02:12:13 -06:00
app.MapRazorComponents<App>()
.DisableAntiforgery()
2025-02-16 02:12:13 -06:00
.AddInteractiveServerRenderMode();
2025-03-11 21:21:16 -05:00
app.PrepareDirectories();
2025-12-13 00:27:54 -06:00
await app.RunApplicationMigrationsAsync();
await app.RunDatabaseMigrationsAsync();
await app.StartServersAsync();
await app.StartBeaconAsync();
2025-03-11 21:21:16 -05:00
app.GenerateThumbnails();
2025-02-08 15:28:13 -06:00
app.Run();
public partial class Program
{
}