33 lines
1.1 KiB
C#
33 lines
1.1 KiB
C#
var builder = WebApplication.CreateBuilder(new WebApplicationOptions
|
|
{
|
|
Args = args,
|
|
ApplicationName = typeof(Program).Assembly.FullName
|
|
});
|
|
builder.Configuration.SetBasePath(Directory.GetCurrentDirectory());
|
|
builder.Configuration.AddJsonFile("appsettings.json", optional: true);
|
|
builder.Configuration.AddJsonFile($"appsettings.{builder.Environment.EnvironmentName}.json", optional: true);
|
|
builder.Configuration.AddEnvironmentVariables();
|
|
builder.Services.AddCustomHealthCheck(builder.Configuration)
|
|
.Configure<BackgroundTaskSettings>(builder.Configuration)
|
|
.AddHostedService<GracePeriodManagerService>()
|
|
.AddEventBus(builder.Configuration);
|
|
var app = builder.Build();
|
|
if (!app.Environment.IsDevelopment())
|
|
{
|
|
app.UseExceptionHandler("/Home/Error");
|
|
}
|
|
|
|
app.UseRouting();
|
|
|
|
app.MapHealthChecks("/hc", new HealthCheckOptions()
|
|
{
|
|
Predicate = _ => true,
|
|
ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse
|
|
});
|
|
app.MapHealthChecks("/liveness", new HealthCheckOptions
|
|
{
|
|
Predicate = r => r.Name.Contains("self")
|
|
});
|
|
|
|
await app.RunAsync();
|