92 lines
No EOL
1.9 KiB
C#
92 lines
No EOL
1.9 KiB
C#
using LANCommander.Server.UI;
|
|
using LANCommander.Server.Startup;
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
if (args.Contains("--debugger"))
|
|
builder.WaitForDebugger();
|
|
|
|
builder.AddSettings();
|
|
builder.AddAsService();
|
|
builder.AddLogger();
|
|
|
|
builder.AddRazor();
|
|
builder.AddSignalR();
|
|
builder.AddCors();
|
|
builder.AddControllers();
|
|
builder.ConfigureKestrel();
|
|
builder.ConfigureAuthentication();
|
|
builder.AddIdentity();
|
|
builder.AddHangfire();
|
|
builder.AddOpenApi();
|
|
builder.AddServerProcessStatusMonitor();
|
|
builder.AddLANCommanderServices();
|
|
builder.AddMigrations();
|
|
builder.AddDatabase(args);
|
|
|
|
builder.Services.AddHealthChecks();
|
|
|
|
var app = builder.Build();
|
|
|
|
var logger = app.Services.GetRequiredService<ILogger<Program>>();
|
|
logger.LogDebug("Building Application");
|
|
|
|
app.UseDatabase(args);
|
|
app.ValidateSettings();
|
|
|
|
app.UseCors("CorsPolicy");
|
|
app.UseHttpsRedirection();
|
|
|
|
app.MapHealthChecks("/Health");
|
|
|
|
app.UseMiddlewares();
|
|
|
|
// Configure the HTTP request pipeline.
|
|
if (app.Environment.IsDevelopment())
|
|
{
|
|
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();
|
|
}
|
|
|
|
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.RunApplicationMigrationsAsync();
|
|
await app.RunDatabaseMigrationsAsync();
|
|
await app.StartServersAsync();
|
|
await app.StartBeaconAsync();
|
|
|
|
app.GenerateThumbnails();
|
|
|
|
app.Run();
|
|
|
|
public partial class Program
|
|
{
|
|
} |