You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.6 KiB
C#

using DS.WMS.JobService;
using DS.Module.HangfireModule;
3 months ago
using Autofac.Extensions.DependencyInjection;
using Autofac;
using DS.Module.AutofacModule;
using DS.Module.SqlSugar;
using DS.Module.UserModule;
using DS.Module.RedisModule;
using Hangfire;
using DS.WMS.Core.HangfireJob.Interface;
using DS.WMS.Core.HangfireJob.Method;
using Microsoft.AspNetCore.Http;
using NLog.Web;
var builder = Host.CreateApplicationBuilder(args);
//Ӧ<><D3A6><EFBFBD><EFBFBD>Ϊ Windows <20><><EFBFBD><EFBFBD>
builder.Services.AddWindowsService();
//ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
builder.Configuration
.AddJsonFile(path: "appsettings.json", optional: false, reloadOnChange: true)
.Build();
builder.Configuration.AddEnvironmentVariables();
builder.Logging.AddNLog("nlog.config");
3 months ago
//Autofacע<63><D7A2>
builder.ConfigureContainer(new AutofacServiceProviderFactory(), builder => builder.RegisterModule(new AutofacModuleRegister()));
builder.Services.AddTransient<IProblemDetailsWriter, SampleProblemDetailsWriter>();
//builder.Services.AddExceptionHandler<GlobalExceptionsFilter>(); //ȫ<><C8AB><EFBFBD>
builder.Services.AddControllers(options =>
{
options.Filters.Add<GlobalExceptionsFilter>();
});
3 months ago
builder.Services.AddUserModuleInstall(); //<2F>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>
builder.Services.AddRedisModuleInstall();//redis
builder.Services.AddSqlSugarInstall();
builder.Services.AddSaasDbInstall();//<2F>ֿ<EFBFBD><D6BF><EFBFBD><EFBFBD><EFBFBD>
//ע<><D7A2>hangfire
builder.Services.AddWorkServiceHangfireModuleInstall();
3 months ago
builder.Services.AddHostedService<Worker>();
//<2F><><EFBFBD><EFBFBD> BackgroundService <20>д<EFBFBD><D0B4><EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><ECB3A3><EFBFBD><EFBFBD>ֹͣ<CDA3><D6B9><EFBFBD><EFBFBD>
builder.Services.Configure<HostOptions>(hostOptions =>
{
hostOptions.BackgroundServiceExceptionBehavior = BackgroundServiceExceptionBehavior.Ignore;
});
var host = builder.Build();
3 months ago
host.Run();