1
0
mirror of https://github.com/bitwarden/server.git synced 2025-05-29 15:24:51 -05:00
bitwarden/src/Notifications/Jobs/JobsHostedService.cs
2018-08-23 21:56:48 -04:00

41 lines
1.2 KiB
C#

using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Bit.Core.Jobs;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Quartz;
namespace Bit.Notifications.Jobs
{
public class JobsHostedService : BaseJobsHostedService
{
public JobsHostedService(
IServiceProvider serviceProvider,
ILogger<JobsHostedService> logger,
ILogger<JobListener> listenerLogger)
: base(serviceProvider, logger, listenerLogger) { }
public override async Task StartAsync(CancellationToken cancellationToken)
{
var everyFiveMinutesTrigger = TriggerBuilder.Create()
.StartNow()
.WithCronSchedule("0 */30 * * * ?")
.Build();
Jobs = new List<Tuple<Type, ITrigger>>
{
new Tuple<Type, ITrigger>(typeof(LogConnectionCounterJob), everyFiveMinutesTrigger)
};
await base.StartAsync(cancellationToken);
}
public static void AddJobsServices(IServiceCollection services)
{
services.AddTransient<LogConnectionCounterJob>();
}
}
}