From 7774f38c1a14f332b26d2ad1402551778c135e1e Mon Sep 17 00:00:00 2001 From: JianWeie Date: Sat, 4 Sep 2021 00:56:33 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BC=98=E5=8C=96=E3=80=91=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1=E7=BB=84=E4=BB=B6?= =?UTF-8?q?HangFire=E5=88=9D=E5=A7=8B=E5=8C=96=E9=85=8D=E7=BD=AE=E6=96=B9?= =?UTF-8?q?=E5=BC=8F=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CoreCms.Net.Core/Config/HangFireSetup.cs | 10 ++++++++++ CoreCms.Net.Web.WebApi/Startup.cs | 10 ---------- 2 files changed, 10 insertions(+), 10 deletions(-) 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