Reorganized project structure to separate backend process from frontend process.
This commit is contained in:
52
ReportingServices.UI/Program.cs
Normal file
52
ReportingServices.UI/Program.cs
Normal file
@ -0,0 +1,52 @@
|
||||
using ReportingServices.Shared.Repositories;
|
||||
using Serilog;
|
||||
|
||||
LoggerConfiguration loggerConfiguration = new();
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
Environment.SetEnvironmentVariable("workingDirectory", "C:/tmp/logging");
|
||||
_ = ConfigurationLoggerConfigurationExtensions.Configuration(loggerConfiguration.ReadFrom, builder.Configuration);
|
||||
_ = SerilogHostBuilderExtensions.UseSerilog(builder.Host);
|
||||
Log.Logger = loggerConfiguration.CreateLogger();
|
||||
Serilog.ILogger log = Log.ForContext<Program>();
|
||||
|
||||
|
||||
// Add services to the container.
|
||||
builder.Services.AddControllersWithViews();
|
||||
builder.Services.AddScoped<IScrapeDatabaseRepository, ScrapeDatabaseRepository>();
|
||||
builder.Services.AddScoped<IFabTimeReportingRepository, FabTimeReportingRepository>();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (!app.Environment.IsDevelopment())
|
||||
{
|
||||
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.UseHttpsRedirection();
|
||||
app.UseStaticFiles();
|
||||
|
||||
app.UseRouting();
|
||||
|
||||
app.UseAuthorization();
|
||||
|
||||
app.MapControllerRoute(
|
||||
name: "default",
|
||||
pattern: "{controller=Home}/{action=Index}/{id?}");
|
||||
_ = app.Lifetime.ApplicationStopped.Register(Log.CloseAndFlush);
|
||||
log.Information("Starting Web Application");
|
||||
try
|
||||
{
|
||||
app.Run();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
log.Fatal(ex, "Host terminated unexpectedly");
|
||||
}
|
||||
finally
|
||||
{
|
||||
Log.CloseAndFlush();
|
||||
}
|
Reference in New Issue
Block a user