|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
-
- using Newtonsoft.Json;
- using Newtonsoft.Json.Serialization;
- using Serilog;
- using TelpoDataService.Util.Clients;
- using TelpoPush.Position.Worker;
- using TelpoPush.Position.Worker.Common;
- using TelpoPush.Position.Worker.Handlers;
- using TelpoPush.Position.Worker.Service.Cache;
- using TelpoPush.Position.Worker.Service.Mq;
-
-
- #region ��־
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- var configuration = new ConfigurationBuilder()
- .SetBasePath(Directory.GetCurrentDirectory())
- .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
- .Build();
-
- Log.Logger = new LoggerConfiguration()
- .ReadFrom.Configuration(configuration)
- .Enrich.WithThreadId()
- .CreateLogger();
- #endregion
- try
- {
- Log.Information("Starting up");
- var builder = Host.CreateApplicationBuilder(args);
-
- var config = builder.Configuration;
-
-
-
-
- JsonSerializerSettings setting = new JsonSerializerSettings();
- JsonConvert.DefaultSettings = () =>
- {
- setting.DateFormatString = "yyyy-MM-dd HH:mm:ss";
- setting.ContractResolver = new CamelCasePropertyNamesContractResolver();
- return setting;
- };
- builder.Services.AddTelpoDataServices(opt =>
- {
- opt.TelpoDataUrl = config["ServiceConfig:TelpoDataUrl"];
- });
-
- builder.Services.AddSerilog();
- builder.Services.AddHttpClient();
- builder.Services.AddTransient<HttpHelperAsync>();
- builder.Services.AddSingleton<SqlMapper>();
- builder.Services.AddSingleton<RedisUtil>();
- builder.Services.AddSingleton<IKafkaService, KafkaService>();
- builder.Services.AddSingleton<KafkaSubscribe>();
- builder.Services.AddSingleton<MessageProducer>();
- builder.Services.AddSingleton<MqProcessMessage>();
- builder.Services.AddSingleton<PositionProcess>();
- builder.Services.AddHostedService<Worker>();
- var host = builder.Build();
- host.Run();
- }
- catch (Exception ex)
- {
- Log.Fatal(ex, "Application start-up failed");
- }
- finally
- {
- Log.CloseAndFlush();
- }
|