iotgateway/IoTGateway/Program.cs

58 lines
2.8 KiB
C#
Raw Normal View History

2022-04-13 17:01:24 +08:00
using System;
using System.Collections.Generic;
2021-12-12 14:55:48 +08:00
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
2022-08-23 16:29:29 +08:00
using MQTTnet.AspNetCore;
2021-12-12 14:55:48 +08:00
using WalkingTec.Mvvm.Core;
using NLog;
using NLog.Web;
2021-12-12 14:55:48 +08:00
namespace IoTGateway
{
public class Program
{
public static void Main(string[] args)
{
2022-04-13 17:01:24 +08:00
Console.WriteLine(@"
");
2021-12-12 14:55:48 +08:00
CreateWebHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateWebHostBuilder(string[] args)
{
return
Host.CreateDefaultBuilder(args)
.ConfigureAppConfiguration((hostingContext, config) =>
{
config.AddInMemoryCollection(new Dictionary<string, string> { { "HostRoot", hostingContext.HostingEnvironment.ContentRootPath } });
})
.ConfigureLogging((hostingContext, logging) =>
{
logging.ClearProviders();
logging.AddConsole();
logging.AddWTMLogger();
})
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
webBuilder.UseKestrel(option =>
{
option.ListenAnyIP(1888, l => l.UseMqtt());
2021-12-12 14:55:48 +08:00
option.ListenAnyIP(518);
});
})
.UseNLog();
2021-12-12 14:55:48 +08:00
}
}
}