|
|
|
@ -11,20 +11,22 @@ using DS.WMS.Core.HangfireJob.Interface;
|
|
|
|
|
using DS.WMS.Core.HangfireJob.Method;
|
|
|
|
|
|
|
|
|
|
var builder = Host.CreateApplicationBuilder(args);
|
|
|
|
|
|
|
|
|
|
var environment = builder.Environment.EnvironmentName;
|
|
|
|
|
Console.WriteLine("当前开发环境:" + environment);
|
|
|
|
|
//允许 BackgroundService 中存在未经处理的异常,不停止主机
|
|
|
|
|
builder.Services.Configure<HostOptions>(hostOptions =>
|
|
|
|
|
{
|
|
|
|
|
hostOptions.BackgroundServiceExceptionBehavior = BackgroundServiceExceptionBehavior.Ignore;
|
|
|
|
|
});
|
|
|
|
|
//应用作为 Windows 服务
|
|
|
|
|
builder.Services.AddWindowsService();
|
|
|
|
|
//×¢²áÅäÖÃ
|
|
|
|
|
builder.Configuration
|
|
|
|
|
// .SetBasePath(builder.Environment.ContentRootPath)
|
|
|
|
|
.AddJsonFile(path: "appsettings.json", optional: false, reloadOnChange: true)
|
|
|
|
|
// .AddJsonFile(path: $"appsettings.{environment}.json", optional: true, reloadOnChange: true)
|
|
|
|
|
.Build();
|
|
|
|
|
builder.Configuration.AddEnvironmentVariables();
|
|
|
|
|
//Autofac×¢Èë
|
|
|
|
|
builder.ConfigureContainer(new AutofacServiceProviderFactory(), builder => builder.RegisterModule(new AutofacModuleRegister()));
|
|
|
|
|
|
|
|
|
|
builder.Services.AddExceptionHandler<ArgumentExceptionHandler>(); //全局异常
|
|
|
|
|
//builder.Services.AddExceptionHandler<ArgumentExceptionHandler>(); //全局异常
|
|
|
|
|
builder.Services.AddUserModuleInstall(); //Óû§·þÎñ
|
|
|
|
|
builder.Services.AddRedisModuleInstall();//redis
|
|
|
|
|
builder.Services.AddSqlSugarInstall();
|
|
|
|
@ -34,14 +36,6 @@ builder.Services.AddWorkServiceHangfireModuleInstall();
|
|
|
|
|
|
|
|
|
|
builder.Services.AddHostedService<Worker>();
|
|
|
|
|
|
|
|
|
|
//允许 BackgroundService 中存在未经处理的异常,不停止主机
|
|
|
|
|
builder.Services.Configure<HostOptions>(hostOptions =>
|
|
|
|
|
{
|
|
|
|
|
hostOptions.BackgroundServiceExceptionBehavior = BackgroundServiceExceptionBehavior.Ignore;
|
|
|
|
|
});
|
|
|
|
|
//应用作为 Windows 服务
|
|
|
|
|
builder.Services.AddWindowsService();
|
|
|
|
|
|
|
|
|
|
var host = builder.Build();
|
|
|
|
|
|
|
|
|
|
host.Run();
|
|
|
|
|