Refactored quartz client registration
This commit is contained in:
@@ -146,12 +146,6 @@ builder.Services.AddCors(options =>
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
var schedulerFactory = app.Services.GetRequiredService<ISchedulerFactory>();
|
||||
var scheduler = await schedulerFactory.GetScheduler();
|
||||
|
||||
if (scheduler!.Status != SchedulerStatus.Running)
|
||||
await scheduler.Start();
|
||||
|
||||
app.UseCors(CorsPolicy);
|
||||
app.UseHsts();
|
||||
app.UseHttpsRedirection();
|
||||
|
||||
@@ -20,7 +20,7 @@ public static class Quartz
|
||||
services.AddQuartz(config =>
|
||||
{
|
||||
config.UseSimpleTypeLoader();
|
||||
config.UseDefaultThreadPool(options => options.MaxConcurrency = 1);
|
||||
config.UseThreadPool<global::Quartz.Impl.ZeroSizeThreadPool>();
|
||||
config.UseTimeZoneConverter();
|
||||
|
||||
config.UsePersistentStore(storage =>
|
||||
|
||||
@@ -11,8 +11,8 @@ public sealed class QuartzHealthCheck(ISchedulerFactory schedulerFactory) : IHea
|
||||
if (scheduler == null)
|
||||
return HealthCheckResult.Unhealthy($"Scheduler with name '{DefaultSchedulerName}' not found.");
|
||||
|
||||
if (scheduler.Status != SchedulerStatus.Running)
|
||||
return HealthCheckResult.Unhealthy($"{DefaultSchedulerName} Quartz scheduler is not running");
|
||||
if (scheduler.Status != SchedulerStatus.Running && scheduler.Status != SchedulerStatus.Standby)
|
||||
return HealthCheckResult.Unhealthy($"{DefaultSchedulerName} Quartz scheduler is not available");
|
||||
|
||||
await scheduler.Exists(new JobKey(Guid.NewGuid().ToString()), cancellationToken);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user