namespace JiShe.CollectBusEPO
{
    public class Program
    {
        public static void Main(string[] args)
        {
            CreateHostBuilder(args).Build().Run();

        }

        private static IHostBuilder CreateHostBuilder(string[] args)
        {
            var env = Environment.GetEnvironmentVariable("RUN_ENV") ?? "Development";

            return Host.CreateDefaultBuilder(args)
               .UseEnvironment(env)
               .ConfigureAppConfiguration((context, builder) =>
               {
                   var c = builder.Build();

                   builder.AddJsonFile($"appsettings.json", false, true);
                   builder.AddJsonFile($"appsettings.{env}.json", false, true);

                   //builder.AddNacosV2Configuration(c.GetSection("NacosConfig"));
               })
               .ConfigureWebHostDefaults(webBuilder =>
               {
                   var runPort = Environment.GetEnvironmentVariable("RUN_PORT") ?? "8088";
                   webBuilder.ConfigureKestrel((context, options) => { options.Limits.MaxRequestBodySize = 1024 * 50; });
                   webBuilder.UseStartup<Startup>();
                   webBuilder.UseUrls($"http://*:{runPort}");
               })
               .UseSerilog((context, loggerConfiguration) =>
               {
                   loggerConfiguration.ReadFrom.Configuration(context.Configuration);
               }).UseAutofac();
        }
    }
}
