-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
46 lines (40 loc) · 1.22 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
using Darwin.Installers;
using Serilog;
#pragma warning disable 8625, 8603, 8618, 1998, 8601
Log.Logger = SerilogInstaller.BootstrapSerilog();
Log.Information("Starting up");
var builder = WebApplication.CreateBuilder(args);
try
{
// add services
builder.Services.InstallOptions(builder.Configuration);
builder.Services.InstallProjectServices();
builder.Services.InstallDb(builder.Configuration);
builder.Services.InstallIdentity(builder.Configuration);
builder.Services.InstallJwt(builder.Configuration);
builder.Services.InstallMvc();
builder.Services.InstallAutomapper();
builder.Services.InstallSwagger();
builder.Services.InstallCors();
builder.Host.InstallSerilog();
var app = builder.Build();
app.InstallCreateMigrateSeedDb();
// http-request pipeline
app.InstallRequestPipeline();
app.Run();
}
catch (Exception ex)
{
// exception handling for "default exception" when host ist interrupted while db migrate
string type = ex.GetType().Name;
if (type.Equals("StopTheHostException", StringComparison.Ordinal))
{
throw;
}
Log.Fatal(ex, "Unhandled exception");
}
finally
{
Log.Information("Shut down complete");
Log.CloseAndFlush();
}