mirror of
https://github.com/FastTunnel/FastTunnel.git
synced 2025-02-08 10:59:31 +08:00
54 lines
1.8 KiB
C#
54 lines
1.8 KiB
C#
using FastTunnel.Core.Extensions;
|
|
using FastTunnel.Core.Services;
|
|
using Microsoft.AspNetCore.Hosting;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Hosting;
|
|
using Microsoft.Extensions.Logging;
|
|
using NLog.Web;
|
|
using System;
|
|
|
|
namespace FastTunnel.Server
|
|
{
|
|
public class Program
|
|
{
|
|
public static void Main(string[] args)
|
|
{
|
|
var logger = NLogBuilder.ConfigureNLog("nlog.config").GetCurrentClassLogger();
|
|
try
|
|
{
|
|
CreateHostBuilder(args).Build().Run();
|
|
}
|
|
catch (Exception exception)
|
|
{
|
|
//NLog: catch setup errors
|
|
logger.Error(exception, "Stopped program because of exception");
|
|
throw;
|
|
}
|
|
finally
|
|
{
|
|
// Ensure to flush and stop internal timers/threads before application-exit (Avoid segmentation fault on Linux)
|
|
NLog.LogManager.Shutdown();
|
|
}
|
|
}
|
|
|
|
public static IHostBuilder CreateHostBuilder(string[] args) =>
|
|
Host.CreateDefaultBuilder(args)
|
|
.ConfigureServices((hostContext, services) =>
|
|
{
|
|
// -------------------FastTunnel START------------------
|
|
services.AddFastTunnelServer();
|
|
// -------------------FastTunnel END--------------------
|
|
})
|
|
.ConfigureWebHostDefaults(webBuilder =>
|
|
{
|
|
webBuilder.UseStartup<Startup>();
|
|
})
|
|
.ConfigureLogging((HostBuilderContext context, ILoggingBuilder logging) =>
|
|
{
|
|
logging.ClearProviders();
|
|
logging.SetMinimumLevel(LogLevel.Trace);
|
|
})
|
|
.UseNLog(); // NLog: Setup NLog for Dependency injection
|
|
}
|
|
}
|