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