2025-05-06 06:45:49 +00:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.IO;
|
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
using Microsoft.AspNetCore.Builder;
|
|
|
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
|
using Microsoft.Extensions.Hosting;
|
|
|
|
|
|
using Serilog;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Kurs.Platform;
|
|
|
|
|
|
|
|
|
|
|
|
public class Program
|
|
|
|
|
|
{
|
|
|
|
|
|
public async static Task<int> Main(string[] args)
|
|
|
|
|
|
{
|
|
|
|
|
|
var configuration = new ConfigurationBuilder()
|
|
|
|
|
|
.SetBasePath(Directory.GetCurrentDirectory())
|
|
|
|
|
|
.AddJsonFile("appsettings.json")
|
|
|
|
|
|
.AddJsonFile($"appsettings.{Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? ""}.json", true)
|
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
|
|
Log.Logger = new LoggerConfiguration()
|
|
|
|
|
|
.ReadFrom.Configuration(configuration)
|
|
|
|
|
|
.CreateLogger();
|
2025-05-07 06:55:09 +00:00
|
|
|
|
|
2025-05-06 06:45:49 +00:00
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
Log.Information("Starting Kurs.Platform.HttpApi.Host.");
|
|
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
|
|
builder.Host.AddAppSettingsSecretsJson()
|
|
|
|
|
|
.UseAutofac()
|
|
|
|
|
|
.UseSerilog();
|
|
|
|
|
|
await builder.AddApplicationAsync<PlatformHttpApiHostModule>();
|
|
|
|
|
|
var app = builder.Build();
|
|
|
|
|
|
await app.InitializeApplicationAsync();
|
|
|
|
|
|
await app.RunAsync();
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (ex is HostAbortedException)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Log.Fatal(ex, "Host terminated unexpectedly!");
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
finally
|
|
|
|
|
|
{
|
|
|
|
|
|
Log.CloseAndFlush();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|