From 47f28a1ee81532e806a8890fae0913ff5770fc66 Mon Sep 17 00:00:00 2001 From: Christiaan Bloemendaal Date: Mon, 1 Jan 2024 16:21:19 +0100 Subject: [PATCH] fix: properly starting jobs --- src/Mangarr.Backend/Program.cs | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/Mangarr.Backend/Program.cs b/src/Mangarr.Backend/Program.cs index d496737..fe7f255 100644 --- a/src/Mangarr.Backend/Program.cs +++ b/src/Mangarr.Backend/Program.cs @@ -56,7 +56,6 @@ configure .WithIdentity("CacheSourceSchedulerJob") .ForJob(CacheSourceSchedulerJob.JobKey) - .StartNow() .WithCronSchedule("0 0/30 0 ? * * *"); }); @@ -65,7 +64,6 @@ configure .WithIdentity("IndexMangaSchedulerJob") .ForJob(IndexMangaSchedulerJob.JobKey) - .StartNow() .WithCronSchedule("0 0 * ? * * *"); }); @@ -174,6 +172,27 @@ } } +{ + ISchedulerFactory schedulerFactory = app.Services.GetRequiredService(); + IScheduler scheduler = await schedulerFactory.GetScheduler(); + + ITrigger indexMangaTrigger = TriggerBuilder.Create() + .WithIdentity("LaunchIndexMangaSchedulerJob") + .ForJob(IndexMangaSchedulerJob.JobKey) + .StartAt(DateTimeOffset.UtcNow.AddSeconds(15)) + .Build(); + + await scheduler.ScheduleJob(indexMangaTrigger); + + ITrigger downloadChapterTrigger = TriggerBuilder.Create() + .WithIdentity("LaunchDownloadChapterSchedulerJob") + .ForJob(DownloadChapterSchedulerJob.JobKey) + .StartAt(DateTimeOffset.UtcNow.AddSeconds(30)) + .Build(); + + await scheduler.ScheduleJob(downloadChapterTrigger); +} + await app.RunAsync(); namespace Mangarr.Backend