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