# 2022-01-24

###  开源社区版(会员专业版同步修改):
【完善】实现营销结果【GOODS_HALF_PRICE】指定商品每第几件减指定金额。
### 0.1.2 会员专业版:
【新增】微信直播带货组件添加支持base64上传到微信侧功能。
【优化】定时任务调整工作线程数及日志数量。
【优化】定时任务执行时间基准调整为本地loacl时间。
This commit is contained in:
JianWeie
2022-01-24 02:27:26 +08:00
parent f1d02b6f89
commit b5addd52cf
5 changed files with 129 additions and 27 deletions

View File

@@ -16,6 +16,8 @@ using CoreCms.Net.Configuration;
using CoreCms.Net.Utility.Extensions;
using Hangfire;
using Hangfire.MySql;
using Hangfire.Redis;
using Hangfire.SqlServer;
using Microsoft.Extensions.DependencyInjection;
using SqlSugar;
@@ -34,7 +36,13 @@ namespace CoreCms.Net.Core.Config
var isEnabledRedis = AppSettingsConstVars.RedisUseTimedTask;
if (isEnabledRedis)
{
services.AddHangfire(x => x.UseRedisStorage(AppSettingsConstVars.RedisConfigConnectionString));
services.AddHangfire(x => x.UseRedisStorage(AppSettingsConstVars.RedisConfigConnectionString, new RedisStorageOptions()
{
Db = 10,
SucceededListSize = 500,//后续列表中的最大可见后台作业,以防止它无限增长。
DeletedListSize = 500,//删除列表中的最大可见后台作业,以防止其无限增长。
InvisibilityTimeout = TimeSpan.FromMinutes(30),
}));
}
else
{
@@ -48,14 +56,22 @@ namespace CoreCms.Net.Core.Config
JobExpirationCheckInterval = TimeSpan.FromHours(1), //- 作业到期检查间隔管理过期记录。默认值为1小时。
CountersAggregateInterval = TimeSpan.FromMinutes(5), //- 聚合计数器的间隔。默认为5分钟。
PrepareSchemaIfNecessary = true, //- 如果设置为true则创建数据库表。默认是true。
DashboardJobListLimit = 50000, //- 仪表板作业列表限制。默认值为50000。
DashboardJobListLimit = 500, //- 仪表板作业列表限制。默认值为50000。
TransactionTimeout = TimeSpan.FromMinutes(1), //- 交易超时。默认为1分钟。
TablesPrefix = "Hangfire" //- 数据库中表的前缀。默认为none
})));
}
else if (dbTypeString == DbType.SqlServer.ToString())
{
services.AddHangfire(x => x.UseSqlServerStorage(AppSettingsConstVars.DbSqlConnection));
services.AddHangfire(x => x.UseSqlServerStorage(AppSettingsConstVars.DbSqlConnection, new SqlServerStorageOptions()
{
QueuePollInterval = TimeSpan.FromSeconds(15), //- 作业队列轮询间隔。默认值为15秒。
JobExpirationCheckInterval = TimeSpan.FromHours(1), //- 作业到期检查间隔管理过期记录。默认值为1小时。
CountersAggregateInterval = TimeSpan.FromMinutes(5), //- 聚合计数器的间隔。默认为5分钟。
PrepareSchemaIfNecessary = true, //- 如果设置为true则创建数据库表。默认是true。
DashboardJobListLimit = 500, //- 仪表板作业列表限制。默认值为50000。
TransactionTimeout = TimeSpan.FromMinutes(1), //- 交易超时。默认为1分钟。
}));
}
}
@@ -64,8 +80,9 @@ namespace CoreCms.Net.Core.Config
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
options.ShutdownTimeout = TimeSpan.FromMinutes(5); //超时时间
//options.WorkerCount = Math.Max(Environment.ProcessorCount, 2); //工作线程数当前允许的最大线程默认20
options.WorkerCount = 2; //工作线程数当前允许的最大线程默认20
});
}