Browse Source

hangfire改redis

master
wxd 3 months ago
parent
commit
d2a8319539
  1. 16
      src/Shentun.Peis.HttpApi.Host/PeisHttpApiHostModule.cs
  2. 2
      src/Shentun.Peis.HttpApi.Host/Shentun.Peis.HttpApi.Host.csproj
  3. 8
      src/Shentun.Peis.HttpApi.Host/appsettings.json

16
src/Shentun.Peis.HttpApi.Host/PeisHttpApiHostModule.cs

@ -59,7 +59,6 @@ using Volo.Abp.SecurityLog;
using Volo.Abp.Auditing;
using Volo.Abp.BackgroundWorkers.Hangfire;
using Hangfire;
using Hangfire.PostgreSql;
using Volo.Abp.BackgroundWorkers;
using Shentun.Peis.Schedulers;
using System.Threading.Tasks;
@ -74,6 +73,7 @@ using Microsoft.AspNetCore.DataProtection;
using Volo.Abp.OpenIddict;
using System.Security.Cryptography.X509Certificates;
using Shentun.Peis.Controllers;
using Hangfire.Redis;
namespace Shentun.Peis;
@ -88,6 +88,7 @@ namespace Shentun.Peis;
typeof(AbpAspNetCoreSerilogModule),
typeof(AbpSwashbuckleModule),
typeof(AbpBackgroundWorkersHangfireModule)
)]
public class PeisHttpApiHostModule : AbpModule
{
@ -224,7 +225,7 @@ public class PeisHttpApiHostModule : AbpModule
option.AllowCustomFlow("phone_verify");
});
context.Services.AddTransient<MiniProgramTokenController>();
////虚拟目录
@ -498,12 +499,19 @@ public class PeisHttpApiHostModule : AbpModule
private void ConfigureHangfire(ServiceConfigurationContext context, IConfiguration configuration)
{
//context.Services.AddHangfire(config =>
//{
// config.UsePostgreSqlStorage(configuration.GetConnectionString("Default"));
//});
context.Services.AddHangfire(config =>
{
config.UsePostgreSqlStorage(configuration.GetConnectionString("Default"));
config.UseRedisStorage(configuration["Hangfire:ConnectionStrings"], new RedisStorageOptions
{
Db = string.IsNullOrWhiteSpace(configuration["Hangfire:Db"]) ? 0 : Convert.ToInt32(configuration["Hangfire:Db"])
});
});
}
public override async void OnApplicationInitialization(ApplicationInitializationContext context)
{

2
src/Shentun.Peis.HttpApi.Host/Shentun.Peis.HttpApi.Host.csproj

@ -10,7 +10,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Hangfire.PostgreSql" Version="1.7.0" />
<PackageReference Include="Hangfire.Redis.StackExchange" Version="1.8.5" />
<PackageReference Include="Serilog.AspNetCore" Version="5.0.0" />
<PackageReference Include="Serilog.Sinks.Async" Version="1.5.0" />
<PackageReference Include="Volo.Abp.AspNetCore.MultiTenancy" Version="6.0.0" />

8
src/Shentun.Peis.HttpApi.Host/appsettings.json

@ -13,7 +13,7 @@
},
"ConnectionStrings": {
//"Default": "Host=10.1.12.140;Port=5432;Database=ShentunPeis0508;User ID=postgres;Password=st123;"
"Default": "Host=140.143.162.39;Port=5432;Database=ShentunPeis240701;User ID=postgres;Password=shentun123;"
"Default": "Host=140.143.162.39;Port=5432;Database=ShentunPeis240701;User ID=postgres;Password=shentun123;"
//"Default": "Host=192.168.2.67;Port=5432;Database=ShentunPeis;User ID=postgres;Password=st123;"
},
"AuthServer": {
@ -59,8 +59,10 @@
"IsEnabled": true
},
"Hangfire": {
"IsEnabled": false,
"IsEnabledDashboard": false
"IsEnabled": true,
"IsEnabledDashboard": true,
"ConnectionStrings": "127.0.0.1:6379,password=wxd123",
"Db": 3
},
"Pacs": {
"AuthString": "peis:peis@123",

Loading…
Cancel
Save