59 lines
2.2 KiB
C#
59 lines
2.2 KiB
C#
using System;
|
|
using Autofac.Extensions.DependencyInjection;
|
|
using Dicom.Imaging;
|
|
using Microsoft.AspNetCore.Hosting;
|
|
using Microsoft.Extensions.Hosting;
|
|
using Microsoft.Extensions.Logging;
|
|
using NLog.Web;
|
|
|
|
namespace IRaCIS.Core.API
|
|
{
|
|
public class Program
|
|
{
|
|
public static void Main(string[] args)
|
|
{
|
|
ImageManager.SetImplementation(WinFormsImageManager.Instance);
|
|
var logger = NLog.Web.NLogBuilder.ConfigureNLog("nlog.config").GetCurrentClassLogger();
|
|
try
|
|
{
|
|
logger.Debug("init main");
|
|
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)
|
|
.ConfigureWebHostDefaults(webBuilder =>
|
|
{
|
|
webBuilder.ConfigureKestrel((context, options) =>
|
|
{
|
|
//设置应用服务器Kestrel请求体最大为1GB // if don't set default value is: 30 MB
|
|
options.Limits.MaxRequestBodySize = long.MaxValue;
|
|
options.Limits.KeepAliveTimeout = TimeSpan.FromMinutes(30);
|
|
options.Limits.RequestHeadersTimeout = TimeSpan.FromMinutes(30);
|
|
});
|
|
webBuilder.UseStartup<Startup>();
|
|
})//使用Autofac替代本身容器
|
|
.UseServiceProviderFactory(new AutofacServiceProviderFactory()).
|
|
ConfigureLogging(logging =>
|
|
{
|
|
logging.ClearProviders();
|
|
logging.SetMinimumLevel(Microsoft.Extensions.Logging.LogLevel.Trace);
|
|
})
|
|
.UseNLog()
|
|
; // NLog: Setup NLog for Dependency injection;
|
|
|
|
}
|
|
}
|