mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 19:46:29 +00:00
add quartz for jobs
configure auto-scan folder and create hls files job WIP
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
using Azaion.Repository.Jobs;
|
||||
using Quartz;
|
||||
|
||||
namespace Azaion.Repository.Extensions
|
||||
{
|
||||
public static class QuartzJobConfigHelper
|
||||
{
|
||||
public static IServiceCollectionQuartzConfigurator RegisterJob<T>(this IServiceCollectionQuartzConfigurator q,
|
||||
string cron, TimeSpan? startForDebug = null) where T: BaseJob
|
||||
{
|
||||
var jobName = typeof(T).Name;
|
||||
var jobKey = new JobKey(jobName);
|
||||
q.AddJob<T>(jobKey);
|
||||
q.AddTrigger(t => t.WithIdentity($"{jobName}_TRIGGER")
|
||||
.ForJob(jobKey)
|
||||
#if DEBUG
|
||||
.StartAt(DateTimeOffset.Now.Add(startForDebug ?? TimeSpan.FromHours(10)))
|
||||
.WithSimpleSchedule(b => b.WithIntervalInHours(5))
|
||||
#else
|
||||
.StartAt(DateTimeOffset.Now.AddMinutes(1))
|
||||
.WithCronSchedule(cron, builder => builder.InTimeZone(TimeZoneInfo.Utc))
|
||||
#endif
|
||||
);
|
||||
return q;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user