- ABP Framework version: v5.2.2
- UI Type: Angular
- Database System: EF Core (SQL Server)
- Tiered (for MVC) or Auth Server Separated (for Angular): yes
- Exception message and full stack trace:
- Steps to reproduce the issue:
Hi, I tried to add the hangfire background job to our identity server, but I encountered an issue that no active servers in the hangfire, below is the screenshot:
and here is the background job module:
[DependsOn(
typeof(AbpBackgroundJobsAbstractionsModule),
typeof(AbpBackgroundJobsHangfireModule)
)]
public class IdentityServerBackgroundJobsModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
var configuration = context.Services.GetConfiguration();
var connectionString = configuration.GetConnectionString("Default");
context.Services.AddHangfire(config =>
{
config.UseSqlServerStorage(connectionString, new Hangfire.SqlServer.SqlServerStorageOptions()
{
SchemaName = "Hangfire"
});
});
}
public override void OnApplicationInitialization(ApplicationInitializationContext context)
{
var app = context.GetApplicationBuilder();
var configuration = context.GetConfiguration();
app.UseHangfireDashboard();
ConfireHangfireJobs(configuration);
}
private void ConfireHangfireJobs(IConfiguration configuration)
{
// remove all the jobs if exist
using (var connection = JobStorage.Current.GetConnection())
{
foreach (var recurringJob in StorageConnectionExtensions.GetRecurringJobs(connection))
{
RecurringJob.RemoveIfExists(recurringJob.Id);
}
}
// add new job
if (Convert.ToBoolean(configuration["RecurringJobs:HousekeepingJob:IsActive"]))
{
RecurringJob.AddOrUpdate<HousekeepingJob>(s => s.ExecuteAsync(), configuration["RecurringJobs:HousekeepingJob:CronSchedule"]);
}
}
}
Any help would be greatly appreciated.
6 Answer(s)
-
0
hi
Is there any info in the logs.txt?
-
0
Hi maliming,
No errors appear in the logs, but I noticed that there is no step for starting Hangfire:
[22:43:16 INF] Start installing Hangfire SQL objects... [22:43:16 INF] Hangfire SQL objects installed. [22:43:30 INF] Starting IdentityServer4 version 4.1.2+997a6cdd643e46cd5762b710c4ddc43574cbec2e [22:43:32 INF] Using the default authentication scheme Identity.Application for IdentityServer
Btw, I have shared the source code with you via email, could you please help us check.
Thank you.
-
0
-
0
Hi maliming,
Thanks for the fix, it is working now.
But may I know why do we need the AddHangfireServer? it is not included in the documentation: https://docs.abp.io/en/abp/latest/Background-Jobs-Hangfire
-
0
hi
You should follow Hangfire's document first.
https://docs.hangfire.io/en/latest/getting-started/aspnet-core-applications.html?highlight=addhangfireserver
-
0
Hi maliming,
ok, noted on this. Thanks for your support.