Skip to content

Commit

Permalink
fix: properly starting jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
Thundernerd committed Jan 1, 2024
1 parent 9f3b324 commit 47f28a1
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions src/Mangarr.Backend/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
configure
.WithIdentity("CacheSourceSchedulerJob")
.ForJob(CacheSourceSchedulerJob.JobKey)
.StartNow()
.WithCronSchedule("0 0/30 0 ? * * *");
});

Expand All @@ -65,7 +64,6 @@
configure
.WithIdentity("IndexMangaSchedulerJob")
.ForJob(IndexMangaSchedulerJob.JobKey)
.StartNow()
.WithCronSchedule("0 0 * ? * * *");
});

Expand Down Expand Up @@ -174,6 +172,27 @@
}
}

{
ISchedulerFactory schedulerFactory = app.Services.GetRequiredService<ISchedulerFactory>();
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
Expand Down

0 comments on commit 47f28a1

Please sign in to comment.