diff --git a/src/Admin/Jobs/JobsHostedService.cs b/src/Admin/Jobs/JobsHostedService.cs index 05d89e7bc8..8ea30c83f7 100644 --- a/src/Admin/Jobs/JobsHostedService.cs +++ b/src/Admin/Jobs/JobsHostedService.cs @@ -52,20 +52,28 @@ namespace Bit.Admin.Jobs .WithCronSchedule("0 0 0 ? * SUN", x => x.InTimeZone(timeZone)) .Build(); - Jobs = new List> + var jobs = new List> { - new Tuple(typeof(AliveJob), everyTopOfTheHourTrigger), new Tuple(typeof(DatabaseExpiredGrantsJob), everyFridayAt10pmTrigger), new Tuple(typeof(DatabaseUpdateStatisticsJob), everySaturdayAtMidnightTrigger), new Tuple(typeof(DatabaseRebuildlIndexesJob), everySundayAtMidnightTrigger) }; + if(!_globalSettings.SelfHosted) + { + jobs.Add(new Tuple(typeof(AliveJob), everyTopOfTheHourTrigger)); + } + + Jobs = jobs; await base.StartAsync(cancellationToken); } - public static void AddJobsServices(IServiceCollection services) + public static void AddJobsServices(IServiceCollection services, bool selfHosted) { - services.AddTransient(); + if(!selfHosted) + { + services.AddTransient(); + } services.AddTransient(); services.AddTransient(); services.AddTransient(); diff --git a/src/Admin/Startup.cs b/src/Admin/Startup.cs index 6ce698fc48..919b7b8710 100644 --- a/src/Admin/Startup.cs +++ b/src/Admin/Startup.cs @@ -72,7 +72,7 @@ namespace Bit.Admin services.Configure(options => options.LowercaseUrls = true); // Jobs service - Jobs.JobsHostedService.AddJobsServices(services); + Jobs.JobsHostedService.AddJobsServices(services, globalSettings.SelfHosted); services.AddHostedService(); if(globalSettings.SelfHosted) {