Program.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. using Hotline.Api;
  2. using Serilog;
  3. using XF.Domain.Authentications;
  4. Log.Logger = new LoggerConfiguration()
  5. .WriteTo.Console()
  6. .CreateBootstrapLogger();
  7. try
  8. {
  9. Log.Information("Hotline service is Starting up");
  10. var builder = WebApplication.CreateBuilder(args);
  11. builder.WebHost.ConfigureKestrel(serverOptions =>
  12. {
  13. serverOptions.Limits.MaxConcurrentConnections = 5000;
  14. serverOptions.Limits.MaxConcurrentUpgradedConnections = 5000;
  15. });
  16. builder.Host
  17. .ConfigureAppConfiguration((hostBuilderContext, configBuilder) =>
  18. {
  19. var path = Path.Combine(Directory.GetCurrentDirectory(), "config");
  20. configBuilder.SetBasePath(path)
  21. #if DEBUG
  22. .AddJsonFile("appsettings.shared.Development.json", true, true)
  23. #else
  24. .AddJsonFile("appsettings.shared.json", true, true)
  25. #endif
  26. .AddJsonFile("appsettings.json", false, true)
  27. .AddJsonFile($"appsettings.{hostBuilderContext.HostingEnvironment.EnvironmentName}.json", true, true)
  28. .AddEnvironmentVariables()
  29. .AddCommandLine(args)
  30. ;
  31. })
  32. .UseSerilog((ctx, lc) => lc
  33. //.WriteTo.Console(outputTemplate: "[{Timestamp:HH:mm:ss} {Level}] {SourceContext}{NewLine}{Message:lj}{NewLine}{Exception}{NewLine}")
  34. .Enrich.FromLogContext()
  35. .ReadFrom.Configuration(ctx.Configuration), true)
  36. ;
  37. //builder.Services.AddControllers().AddNewtonsoftJson();
  38. builder
  39. .ConfigureServices()
  40. .ConfigurePipelines()
  41. .Run();
  42. }
  43. catch (Exception ex)
  44. {
  45. Log.Fatal(ex, "Unhandled exception");
  46. }
  47. finally
  48. {
  49. Log.Information("Shut down complete");
  50. Log.CloseAndFlush();
  51. }