mirror of
https://github.com/bitwarden/server.git
synced 2025-01-13 20:21:22 +01:00
run jobs on EST for cloud version
This commit is contained in:
parent
65e240c177
commit
52758e5749
@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Bit.Core;
|
||||
using Bit.Core.Jobs;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
@ -11,25 +12,34 @@ namespace Bit.Admin.Jobs
|
||||
{
|
||||
public class JobsHostedService : BaseJobsHostedService
|
||||
{
|
||||
private readonly GlobalSettings _globalSettings;
|
||||
|
||||
public JobsHostedService(
|
||||
GlobalSettings globalSettings,
|
||||
IServiceProvider serviceProvider,
|
||||
ILogger<JobsHostedService> logger,
|
||||
ILogger<JobListener> listenerLogger)
|
||||
: base(serviceProvider, logger, listenerLogger) { }
|
||||
: base(serviceProvider, logger, listenerLogger)
|
||||
{
|
||||
_globalSettings = globalSettings;
|
||||
}
|
||||
|
||||
public override async Task StartAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
var timeZone = _globalSettings.SelfHosted ? TimeZoneInfo.Utc :
|
||||
TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time");
|
||||
|
||||
var everyFridayAt1145pmTrigger = TriggerBuilder.Create()
|
||||
.StartNow()
|
||||
.WithCronSchedule("0 45 23 ? * FRI")
|
||||
.WithCronSchedule("0 45 23 ? * FRI", x => x.InTimeZone(timeZone))
|
||||
.Build();
|
||||
var everySaturdayAtMidnightTrigger = TriggerBuilder.Create()
|
||||
.StartNow()
|
||||
.WithCronSchedule("0 0 0 ? * SAT")
|
||||
.WithCronSchedule("0 0 0 ? * SAT", x => x.InTimeZone(timeZone))
|
||||
.Build();
|
||||
var everySundayAtMidnightTrigger = TriggerBuilder.Create()
|
||||
.StartNow()
|
||||
.WithCronSchedule("0 0 0 ? * SUN")
|
||||
.WithCronSchedule("0 0 0 ? * SUN", x => x.InTimeZone(timeZone))
|
||||
.Build();
|
||||
|
||||
Jobs = new List<Tuple<Type, ITrigger>>
|
||||
|
@ -19,9 +19,11 @@ namespace Bit.Billing.Jobs
|
||||
|
||||
public override async Task StartAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
var timeZone = TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time");
|
||||
|
||||
var everyDayAtNinePmTrigger = TriggerBuilder.Create()
|
||||
.StartNow()
|
||||
.WithCronSchedule("0 0 21 * * ?")
|
||||
.WithCronSchedule("0 0 21 * * ?", x => x.InTimeZone(timeZone))
|
||||
.Build();
|
||||
|
||||
Jobs = new List<Tuple<Type, ITrigger>>
|
||||
|
Loading…
Reference in New Issue
Block a user