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.

62 lines
2.0 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 Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using NLog.Web;
var builder = Host.CreateApplicationBuilder(args);
builder.Services.AddWindowsService(options =>
{
options.ServiceName = ".NET Work Service";
});
//ע<><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();
//Ӧ<><D3A6><EFBFBD><EFBFBD>Ϊ Windows <20><><EFBFBD><EFBFBD>
//builder.Services.AddWindowsService();
builder.Services.AddHostedService<WindowsBackgroundService>();
//<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;
hostOptions.ServicesStartConcurrently = true;
hostOptions.ServicesStopConcurrently = true;
});
var host = builder.Build();
3 months ago
host.Run();