25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

45 lines
1.7 KiB

  1. using JT808.Protocol;
  2. using Microsoft.Extensions.Configuration;
  3. using Microsoft.Extensions.DependencyInjection;
  4. using Microsoft.Extensions.Hosting;
  5. using Microsoft.Extensions.Logging;
  6. using System;
  7. using System.Threading.Tasks;
  8. using JT808.Gateway.Kafka;
  9. namespace JT808.Gateway.SimpleQueueServer
  10. {
  11. class Program
  12. {
  13. static async Task Main(string[] args)
  14. {
  15. var serverHostBuilder = new HostBuilder()
  16. .ConfigureAppConfiguration((hostingContext, config) =>
  17. {
  18. config.SetBasePath(AppDomain.CurrentDomain.BaseDirectory);
  19. config.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true);
  20. })
  21. .ConfigureLogging((context, logging) =>
  22. {
  23. logging.AddConsole();
  24. logging.SetMinimumLevel(LogLevel.Trace);
  25. })
  26. .ConfigureServices((hostContext, services) =>
  27. {
  28. services.AddSingleton<ILoggerFactory, LoggerFactory>();
  29. services.AddSingleton(typeof(ILogger<>), typeof(Logger<>));
  30. services.AddJT808Configure()
  31. .AddGateway(hostContext.Configuration)
  32. .AddServerKafkaMsgProducer(hostContext.Configuration)
  33. .AddServerKafkaMsgReplyConsumer(hostContext.Configuration)
  34. .AddServerKafkaSessionProducer(hostContext.Configuration)
  35. .AddTcp()
  36. .AddUdp()
  37. .AddHttp();
  38. });
  39. await serverHostBuilder.RunConsoleAsync();
  40. }
  41. }
  42. }