Learn.VideoAnalysis/VideoAnalysis/Expand/CoravelExpand.cs

35 lines
1.0 KiB
C#

using Coravel;
using Coravel.Scheduling.Schedule;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VideoAnalysisCore.Job;
namespace Learn.VideoAnalysis.Expand
{
public static class CoravelExpand
{
public static void AddCoravel(this IServiceCollection service)
{
Console.WriteLine($"{DateTime.Now}=>初始化 Coravel");
service.AddScheduler();
service.AddTransient<TaskFileClearJob>();
service.AddTransient<NodePackageJob>();
}
public static void UseCoravelExpand(this IApplicationBuilder provider)
{
provider.ApplicationServices.UseScheduler(scheduler =>
{
//任务缓存清理
//scheduler.Schedule<TaskFileClearJob>().HourlyAt(10);
scheduler.Schedule<TaskFileClearJob>().DailyAt(1,0);
});
}
}
}