您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

6 个月前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. using Newtonsoft.Json;
  2. using Newtonsoft.Json.Serialization;
  3. using Serilog;
  4. using TelpoDataService.Util.Clients;
  5. using TelpoPush.Common;
  6. using TelpoPush.Models.Config;
  7. using TelpoPush.Service.Biz;
  8. using TelpoPush.Service.Cache;
  9. using TelpoPush.Service.Mq.Kafka;
  10. using TelpoPush.Worker.ThirdSsl;
  11. using TelpoPush.Worker.ThirdSsl.Handlers;
  12. #region ־
  13. //using Serilog.Events;
  14. //using Serilog;
  15. //using Microsoft.AspNetCore.Builder;
  16. //Log.Logger = new LoggerConfiguration()
  17. //#if DEBUG
  18. // .MinimumLevel.Debug()
  19. //#else
  20. // .MinimumLevel.Information()
  21. //#endif
  22. // .MinimumLevel.Override("Microsoft", LogEventLevel.Information)
  23. // .MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning)
  24. // .Enrich.FromLogContext()
  25. // //.Filter.ByExcluding(c => c.Properties.Any(p => p.Value.ToString().Contains("Microsoft")))//
  26. // .WriteTo.Async(c => c.File("/var/telpo_pushthird_ssl2/logs/infos/info.log",
  27. // restrictedToMinimumLevel: LogEventLevel.Information,
  28. // rollingInterval: RollingInterval.Day,//()
  29. // //fileSizeLimitBytes: 20971520, //õļСΪ3M Ĭ1G
  30. // rollOnFileSizeLimit: true, //ļС󴴽µ
  31. // retainedFileCountLimit: 7,//Ĭ31˼ֻ31־ļ"
  32. // outputTemplate: "{Timestamp:yyyy-MM-dd HH:mm:ss.fff}[{Level:u3}] [Thread-{ThreadId}] [{SourceContext:l}] {Message:lj}{NewLine}{Exception}"
  33. // )
  34. // )
  35. // .WriteTo.Async(c => c.File("/var/telpo_pushthird_ssl2/logs/errors/errors.log",
  36. // restrictedToMinimumLevel: LogEventLevel.Error,
  37. // rollingInterval: RollingInterval.Day,
  38. // rollOnFileSizeLimit: true,
  39. // retainedFileCountLimit: 7,
  40. // outputTemplate: "{Timestamp:yyyy-MM-dd HH:mm:ss.fff }[{Level:u3}] [Thread-{ThreadId}] [{SourceContext:l}] {Message:lj}{NewLine}{Exception}"
  41. // )
  42. // )
  43. // .WriteTo.Async(c => c.Console())
  44. // .CreateLogger();
  45. //ѡļappsetting.json
  46. var configuration = new ConfigurationBuilder()
  47. .SetBasePath(Directory.GetCurrentDirectory())
  48. .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
  49. .Build();
  50. Log.Logger = new LoggerConfiguration()
  51. .ReadFrom.Configuration(configuration)
  52. .Enrich.WithThreadId()
  53. .CreateLogger();
  54. #endregion
  55. try
  56. {
  57. Log.Information("Starting up");
  58. var builder = Host.CreateApplicationBuilder(args);
  59. var config = builder.Configuration;
  60. builder.Services.Configure<ServiceConfig>(config.GetSection("ServiceConfig"));
  61. builder.Services.Configure<RedisConfig>(config.GetSection("Redis"));
  62. JsonSerializerSettings setting = new JsonSerializerSettings();
  63. JsonConvert.DefaultSettings = () =>
  64. {
  65. setting.DateFormatString = "yyyy-MM-dd HH:mm:ss";
  66. setting.ContractResolver = new CamelCasePropertyNamesContractResolver();
  67. return setting;
  68. };
  69. builder.Services.AddTelpoDataServices(opt =>
  70. {
  71. opt.TelpoDataUrl = config["ServiceConfig:TelpoDataUrl"];
  72. });
  73. builder.Services.AddSerilog();
  74. builder.Services.AddHttpClient();
  75. builder.Services.AddTransient<HttpHelperAsync>();
  76. builder.Services.AddSingleton<SqlMapper>();
  77. builder.Services.AddSingleton<RedisUtil>();
  78. builder.Services.AddSingleton<IZkRealHRMonitorService, ZkRealHRMonitorService>();
  79. builder.Services.AddSingleton<IKafkaService, KafkaService>();
  80. builder.Services.AddSingleton<KafkaSubscribe>();
  81. builder.Services.AddSingleton<MessageProducer>();
  82. builder.Services.AddSingleton<MqProcessMessage>();
  83. builder.Services.AddSingleton<ThirdSslProcess>();
  84. builder.Services.AddHostedService<Worker>();
  85. var host = builder.Build();
  86. host.Run();
  87. }
  88. catch (Exception ex)
  89. {
  90. Log.Fatal(ex, "Application start-up failed");
  91. }
  92. finally
  93. {
  94. Log.CloseAndFlush();
  95. }