feat Hnagfire初步搭建

This commit is contained in:
cheche
2023-12-29 16:41:24 +08:00
parent f5c8f659e4
commit 66eacb685a
6 changed files with 58 additions and 1 deletions

View File

@@ -0,0 +1,34 @@
using Hangfire;
using Hangfire.MySql;
using Kurisu.AspNetCore.Startup;
namespace Dlhis.ScheduledTask
{
public class SqlSugarPack1 : BaseAppPack
{
public override bool IsBeforeUseRouting { get; }
public override void ConfigureServices(IServiceCollection services)
{
services.AddHangfire(configuration => configuration
.SetDataCompatibilityLevel(CompatibilityLevel.Version_170)
.UseSimpleAssemblyNameTypeSerializer()
.UseRecommendedSerializerSettings()
.UseStorage(
new MySqlStorage(
Configuration.GetConnectionString("HangfireConnection"),
new MySqlStorageOptions
{
TablesPrefix = "Hangfire" // Adjust other options as needed
}
)
));
services.AddHangfireServer();
}
public override void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.UseHangfireDashboard(); //使用hangfire面板
app.UseHangfireServer(); //启动hangfire服务
}
}
}