using KonSoft.InternalGateway; using KonSoft.Shared.Hosting.AspNetCore; using KonSoft.Shared.Hosting.Gateways; using Serilog; var assemblyName = typeof(Program).Assembly.GetName().Name!; SerilogConfigurationHelper.Configure(assemblyName); try { Log.Information($"Starting {assemblyName}."); var builder = WebApplication.CreateBuilder(args); builder.Configuration .AddAgileConfig(option => { option.ENV = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? "Development"; }); builder.Host .AddAppSettingsSecretsJson() .UseAutofac() .UseSerilog(); await builder.AddApplicationAsync(); var app = builder.Build(); await app.InitializeApplicationAsync(); await app.RunAsync(); return 0; } catch (Exception ex) { Log.Fatal(ex, $"{assemblyName} terminated unexpectedly!"); return 1; } finally { await Log.CloseAndFlushAsync(); }