You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.7 KiB
54 lines
1.7 KiB
using Microsoft.AspNetCore.Builder;
|
|
using Microsoft.AspNetCore.Hosting;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Hosting;
|
|
using Serilog;
|
|
using System;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace LY.MicroService.ApiGateway;
|
|
|
|
public class Program
|
|
{
|
|
public static async Task<int> Main(string[] args)
|
|
{
|
|
try
|
|
{
|
|
Log.Information("Starting Internal ApiGateway.");
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
builder.Host.AddAppSettingsSecretsJson()
|
|
.UseAutofac()
|
|
.ConfigureAppConfiguration((context, config) =>
|
|
{
|
|
var configuration = config.Build();
|
|
if (configuration.GetSection("AgileConfig").Exists())
|
|
{
|
|
config.AddAgileConfig(new AgileConfig.Client.ConfigClient(configuration));
|
|
}
|
|
|
|
config.AddJsonFile("yarp.json", true, true).AddEnvironmentVariables();
|
|
})
|
|
.UseSerilog((context, provider, config) =>
|
|
{
|
|
config.ReadFrom.Configuration(context.Configuration);
|
|
});
|
|
|
|
await builder.AddApplicationAsync<InternalApiGatewayModule>();
|
|
var app = builder.Build();
|
|
await app.InitializeApplicationAsync();
|
|
await app.RunAsync();
|
|
|
|
return 0;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Log.Fatal(ex, "Starting Internal ApiGateway terminated unexpectedly!");
|
|
return 1;
|
|
}
|
|
finally
|
|
{
|
|
Log.CloseAndFlush();
|
|
}
|
|
}
|
|
}
|
|
|