diff --git a/CoreCms.Net.Core/Config/HangFireSetup.cs b/CoreCms.Net.Core/Config/HangFireSetup.cs index 40eead8..57af0e7 100644 --- a/CoreCms.Net.Core/Config/HangFireSetup.cs +++ b/CoreCms.Net.Core/Config/HangFireSetup.cs @@ -58,6 +58,16 @@ namespace CoreCms.Net.Core.Config services.AddHangfire(x => x.UseSqlServerStorage(AppSettingsConstVars.DbSqlConnection)); } } + + services.AddHangfireServer(options => + { + options.Queues = new[] { GlobalEnumVars.HangFireQueuesConfig.@default.ToString(), GlobalEnumVars.HangFireQueuesConfig.apis.ToString(), GlobalEnumVars.HangFireQueuesConfig.web.ToString(), GlobalEnumVars.HangFireQueuesConfig.recurring.ToString() }; + options.ServerTimeout = TimeSpan.FromMinutes(4); + options.SchedulePollingInterval = TimeSpan.FromSeconds(15);//秒级任务需要配置短点,一般任务可以配置默认时间,默认15秒 + options.ShutdownTimeout = TimeSpan.FromMinutes(30); //超时时间 + options.WorkerCount = Math.Max(Environment.ProcessorCount, 20); //工作线程数,当前允许的最大线程,默认20 + }); + } } } diff --git a/CoreCms.Net.Web.WebApi/Startup.cs b/CoreCms.Net.Web.WebApi/Startup.cs index a85005c..56b1688 100644 --- a/CoreCms.Net.Web.WebApi/Startup.cs +++ b/CoreCms.Net.Web.WebApi/Startup.cs @@ -205,16 +205,6 @@ namespace CoreCms.Net.Web.WebApi #region Hangfireʱ - var queues = new string[] { GlobalEnumVars.HangFireQueuesConfig.@default.ToString(), GlobalEnumVars.HangFireQueuesConfig.apis.ToString(), GlobalEnumVars.HangFireQueuesConfig.web.ToString(), GlobalEnumVars.HangFireQueuesConfig.recurring.ToString() }; - app.UseHangfireServer(new BackgroundJobServerOptions - { - ServerTimeout = TimeSpan.FromMinutes(4), - SchedulePollingInterval = TimeSpan.FromSeconds(15),//뼶Ҫö̵㣬һĬʱ䣬Ĭ15 - ShutdownTimeout = TimeSpan.FromMinutes(30),//ʱʱ - Queues = queues,// - WorkerCount = Math.Max(Environment.ProcessorCount, 20)//߳ǰ̣߳Ĭ20 - }); - //Ȩ var filter = new BasicAuthAuthorizationFilter( new BasicAuthAuthorizationFilterOptions