From 10a19c90d333b78f966f29c7a9c9291569604d85 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Thu, 9 Aug 2018 16:08:09 -0400 Subject: [PATCH] Move jobs to api hosted service w/ quartz --- bitwarden-core.sln | 9 +- src/Api/Api.csproj | 1 + src/Api/Dockerfile | 5 - src/Api/Jobs/AliveJob.cs | 23 +++++ src/Api/Jobs/JobFactory.cs | 27 ++++++ src/Api/Jobs/JobListener.cs | 40 ++++++++ src/Api/Jobs/JobsHostedService.cs | 80 +++++++++++++++ src/Api/Jobs/ValidateOrganizationsJob.cs | 34 +++++++ src/Api/Jobs/ValidateUsersJob.cs | 34 +++++++ src/Api/Startup.cs | 10 +- src/Api/build.sh | 3 - src/Api/entrypoint.sh | 7 -- .../Utilities/ServiceCollectionExtensions.cs | 1 - src/Jobs/Jobs.csproj | 25 ----- src/Jobs/NoopServer.cs | 25 ----- src/Jobs/Program.cs | 97 ------------------- src/Jobs/Properties/launchSettings.json | 12 --- src/Jobs/Startup.cs | 74 -------------- src/Jobs/appsettings.Production.json | 17 ---- src/Jobs/appsettings.json | 58 ----------- src/Jobs/crontab | 5 - 21 files changed, 248 insertions(+), 339 deletions(-) create mode 100644 src/Api/Jobs/AliveJob.cs create mode 100644 src/Api/Jobs/JobFactory.cs create mode 100644 src/Api/Jobs/JobListener.cs create mode 100644 src/Api/Jobs/JobsHostedService.cs create mode 100644 src/Api/Jobs/ValidateOrganizationsJob.cs create mode 100644 src/Api/Jobs/ValidateUsersJob.cs delete mode 100644 src/Jobs/Jobs.csproj delete mode 100644 src/Jobs/NoopServer.cs delete mode 100644 src/Jobs/Program.cs delete mode 100644 src/Jobs/Properties/launchSettings.json delete mode 100644 src/Jobs/Startup.cs delete mode 100644 src/Jobs/appsettings.Production.json delete mode 100644 src/Jobs/appsettings.json delete mode 100644 src/Jobs/crontab diff --git a/bitwarden-core.sln b/bitwarden-core.sln index 9d4a755e63..bb3b8bda1d 100644 --- a/bitwarden-core.sln +++ b/bitwarden-core.sln @@ -37,8 +37,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Setup", "util\Setup\Setup.c EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Server", "util\Server\Server.csproj", "{66B0A682-658A-4A82-B606-A077A4871448}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Jobs", "src\Jobs\Jobs.csproj", "{7DCEBD8F-E5F3-4A3C-BD35-B64341590B74}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Function", "util\Function\Function.csproj", "{A6C44A84-8E51-4C64-B9C4-7B7C23253345}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Icons", "src\Icons\Icons.csproj", "{9CF59342-3912-4B45-A2BA-0F173666586D}" @@ -49,7 +47,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EventsProcessor", "src\Even EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Admin", "src\Admin\Admin.csproj", "{B131CEF3-89FB-4C90-ADB0-9E9C4246EB56}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Hub", "src\Hub\Hub.csproj", "{28635027-20E5-42FA-B218-B6C878DE5350}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Hub", "src\Hub\Hub.csproj", "{28635027-20E5-42FA-B218-B6C878DE5350}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -91,10 +89,6 @@ Global {66B0A682-658A-4A82-B606-A077A4871448}.Debug|Any CPU.Build.0 = Debug|Any CPU {66B0A682-658A-4A82-B606-A077A4871448}.Release|Any CPU.ActiveCfg = Release|Any CPU {66B0A682-658A-4A82-B606-A077A4871448}.Release|Any CPU.Build.0 = Release|Any CPU - {7DCEBD8F-E5F3-4A3C-BD35-B64341590B74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7DCEBD8F-E5F3-4A3C-BD35-B64341590B74}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7DCEBD8F-E5F3-4A3C-BD35-B64341590B74}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7DCEBD8F-E5F3-4A3C-BD35-B64341590B74}.Release|Any CPU.Build.0 = Release|Any CPU {A6C44A84-8E51-4C64-B9C4-7B7C23253345}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {A6C44A84-8E51-4C64-B9C4-7B7C23253345}.Debug|Any CPU.Build.0 = Debug|Any CPU {A6C44A84-8E51-4C64-B9C4-7B7C23253345}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -132,7 +126,6 @@ Global {04148736-3C0B-445E-8B74-2020E7A53502} = {DD5BD056-4AAE-43EF-BBD2-0B569B8DA84D} {EF2164EF-1FC0-4518-A2ED-CE02D3630B00} = {DD5BD056-4AAE-43EF-BBD2-0B569B8DA84E} {66B0A682-658A-4A82-B606-A077A4871448} = {DD5BD056-4AAE-43EF-BBD2-0B569B8DA84E} - {7DCEBD8F-E5F3-4A3C-BD35-B64341590B74} = {DD5BD056-4AAE-43EF-BBD2-0B569B8DA84D} {A6C44A84-8E51-4C64-B9C4-7B7C23253345} = {DD5BD056-4AAE-43EF-BBD2-0B569B8DA84E} {9CF59342-3912-4B45-A2BA-0F173666586D} = {DD5BD056-4AAE-43EF-BBD2-0B569B8DA84D} {994DD611-F266-4BD3-8072-3B1B57267ED5} = {DD5BD056-4AAE-43EF-BBD2-0B569B8DA84D} diff --git a/src/Api/Api.csproj b/src/Api/Api.csproj index eb0b60f43e..7cb3c2e2a2 100644 --- a/src/Api/Api.csproj +++ b/src/Api/Api.csproj @@ -18,6 +18,7 @@ + diff --git a/src/Api/Dockerfile b/src/Api/Dockerfile index 2b3f2eba45..724f5371f6 100644 --- a/src/Api/Dockerfile +++ b/src/Api/Dockerfile @@ -4,7 +4,6 @@ LABEL com.bitwarden.product="bitwarden" RUN apt-get update \ && apt-get install -y --no-install-recommends \ - cron \ gosu \ && rm -rf /var/lib/apt/lists/* @@ -12,11 +11,7 @@ ENV ASPNETCORE_URLS http://+:5000 WORKDIR /app EXPOSE 5000 COPY obj/Docker/publish/Api . -COPY obj/Docker/publish/Jobs /jobs COPY entrypoint.sh / RUN chmod +x /entrypoint.sh -RUN mv /jobs/crontab /etc/cron.d/bitwarden-cron \ - && chmod 0644 /etc/cron.d/bitwarden-cron - ENTRYPOINT ["/entrypoint.sh"] diff --git a/src/Api/Jobs/AliveJob.cs b/src/Api/Jobs/AliveJob.cs new file mode 100644 index 0000000000..bc06b8a833 --- /dev/null +++ b/src/Api/Jobs/AliveJob.cs @@ -0,0 +1,23 @@ +using System.Threading.Tasks; +using Microsoft.Extensions.Logging; +using Quartz; + +namespace Bit.Api.Jobs +{ + public class AliveJob : IJob + { + private readonly ILogger _logger; + + public AliveJob( + ILogger logger) + { + _logger = logger; + } + + public Task Execute(IJobExecutionContext context) + { + _logger.LogInformation("It's alive!"); + return Task.FromResult(0); + } + } +} diff --git a/src/Api/Jobs/JobFactory.cs b/src/Api/Jobs/JobFactory.cs new file mode 100644 index 0000000000..57ebed26a1 --- /dev/null +++ b/src/Api/Jobs/JobFactory.cs @@ -0,0 +1,27 @@ +using System; +using Quartz; +using Quartz.Spi; + +namespace Bit.Api.Jobs +{ + public class JobFactory : IJobFactory + { + private readonly IServiceProvider _container; + + public JobFactory(IServiceProvider container) + { + _container = container; + } + + public IJob NewJob(TriggerFiredBundle bundle, IScheduler scheduler) + { + return _container.GetService(bundle.JobDetail.JobType) as IJob; + } + + public void ReturnJob(IJob job) + { + var disposable = job as IDisposable; + disposable?.Dispose(); + } + } +} diff --git a/src/Api/Jobs/JobListener.cs b/src/Api/Jobs/JobListener.cs new file mode 100644 index 0000000000..29c54f8275 --- /dev/null +++ b/src/Api/Jobs/JobListener.cs @@ -0,0 +1,40 @@ +using System; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.Extensions.Logging; +using Quartz; + +namespace Bit.Api.Jobs +{ + public class JobListener : IJobListener + { + private readonly ILogger _logger; + + public JobListener(ILogger logger) + { + _logger = logger; + } + + public string Name => "JobListener"; + + public Task JobExecutionVetoed(IJobExecutionContext context, + CancellationToken cancellationToken = default(CancellationToken)) + { + return Task.FromResult(0); + } + + public Task JobToBeExecuted(IJobExecutionContext context, + CancellationToken cancellationToken = default(CancellationToken)) + { + _logger.LogInformation("Starting job {0} at {1}.", context.JobDetail.JobType.Name, DateTime.UtcNow); + return Task.FromResult(0); + } + + public Task JobWasExecuted(IJobExecutionContext context, JobExecutionException jobException, + CancellationToken cancellationToken = default(CancellationToken)) + { + _logger.LogInformation("Finished job {0} at {1}.", context.JobDetail.JobType.Name, DateTime.UtcNow); + return Task.FromResult(0); + } + } +} diff --git a/src/Api/Jobs/JobsHostedService.cs b/src/Api/Jobs/JobsHostedService.cs new file mode 100644 index 0000000000..c5d2f8bcbe --- /dev/null +++ b/src/Api/Jobs/JobsHostedService.cs @@ -0,0 +1,80 @@ +using System; +using System.Collections.Specialized; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; +using Quartz; +using Quartz.Impl; +using Quartz.Impl.Matchers; + +namespace Bit.Api.Jobs +{ + public class JobsHostedService : IHostedService, IDisposable + { + private readonly IServiceProvider _serviceProvider; + private readonly ILogger _logger; + private readonly ILogger _listenerLogger; + private IScheduler _scheduler; + + public JobsHostedService( + IServiceProvider serviceProvider, + ILogger logger, + ILogger listenerLogger) + { + _serviceProvider = serviceProvider; + _logger = logger; + _listenerLogger = listenerLogger; + } + + public async Task StartAsync(CancellationToken cancellationToken) + { + var factory = new StdSchedulerFactory(new NameValueCollection + { + { "quartz.serializer.type", "binary" } + }); + _scheduler = await factory.GetScheduler(cancellationToken); + _scheduler.JobFactory = new JobFactory(_serviceProvider); + _scheduler.ListenerManager.AddJobListener(new JobListener(_listenerLogger), + GroupMatcher.AnyGroup()); + await _scheduler.Start(cancellationToken); + + var aliveJob = JobBuilder.Create().Build(); + var validateUsersJob = JobBuilder.Create().Build(); + var validateOrganizationsJob = JobBuilder.Create().Build(); + + var everyTopOfTheHourTrigger = TriggerBuilder.Create() + .StartNow() + .WithCronSchedule("0 0 * * * ?") + .Build(); + var everyTopOfTheSixthHourTrigger = TriggerBuilder.Create() + .StartNow() + .WithCronSchedule("0 0 */6 * * ?") + .Build(); + var everyTwelfthHourAndThirtyMinutesTrigger = TriggerBuilder.Create() + .StartNow() + .WithCronSchedule("0 30 */12 * * ?") + .Build(); + + await _scheduler.ScheduleJob(aliveJob, everyTopOfTheHourTrigger); + await _scheduler.ScheduleJob(validateUsersJob, everyTopOfTheSixthHourTrigger); + await _scheduler.ScheduleJob(validateOrganizationsJob, everyTwelfthHourAndThirtyMinutesTrigger); + } + + public async Task StopAsync(CancellationToken cancellationToken) + { + await _scheduler?.Shutdown(cancellationToken); + } + + public void Dispose() + { } + + public static void AddJobsServices(IServiceCollection services) + { + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + } + } +} diff --git a/src/Api/Jobs/ValidateOrganizationsJob.cs b/src/Api/Jobs/ValidateOrganizationsJob.cs new file mode 100644 index 0000000000..bfb2fad3d3 --- /dev/null +++ b/src/Api/Jobs/ValidateOrganizationsJob.cs @@ -0,0 +1,34 @@ +using System; +using System.Threading.Tasks; +using Bit.Core.Services; +using Microsoft.Extensions.Logging; +using Quartz; + +namespace Bit.Api.Jobs +{ + public class ValidateOrganizationsJob : IJob + { + private readonly ILicensingService _licensingService; + private readonly ILogger _logger; + + public ValidateOrganizationsJob( + ILicensingService licensingService, + ILogger logger) + { + _licensingService = licensingService; + _logger = logger; + } + + public async Task Execute(IJobExecutionContext context) + { + try + { + await _licensingService.ValidateOrganizationsAsync(); + } + catch(Exception e) + { + _logger.LogError(2, e, "Error performing {0}.", nameof(ValidateOrganizationsJob)); + } + } + } +} diff --git a/src/Api/Jobs/ValidateUsersJob.cs b/src/Api/Jobs/ValidateUsersJob.cs new file mode 100644 index 0000000000..2018481075 --- /dev/null +++ b/src/Api/Jobs/ValidateUsersJob.cs @@ -0,0 +1,34 @@ +using System; +using System.Threading.Tasks; +using Bit.Core.Services; +using Microsoft.Extensions.Logging; +using Quartz; + +namespace Bit.Api.Jobs +{ + public class ValidateUsersJob : IJob + { + private readonly ILicensingService _licensingService; + private readonly ILogger _logger; + + public ValidateUsersJob( + ILicensingService licensingService, + ILogger logger) + { + _licensingService = licensingService; + _logger = logger; + } + + public async Task Execute(IJobExecutionContext context) + { + try + { + await _licensingService.ValidateUsersAsync(); + } + catch(Exception e) + { + _logger.LogError(2, e, "Error performing {0}.", nameof(ValidateUsersJob)); + } + } + } +} diff --git a/src/Api/Startup.cs b/src/Api/Startup.cs index 2f7e082214..0e4c218264 100644 --- a/src/Api/Startup.cs +++ b/src/Api/Startup.cs @@ -126,9 +126,15 @@ namespace Bit.Api config.Filters.Add(new ModelStateValidationFilterAttribute()); }).AddJsonOptions(o => o.SerializerSettings.ContractResolver = new DefaultContractResolver()); - // PDF generation - if(!globalSettings.SelfHosted) + if(globalSettings.SelfHosted) { + // Jobs service + Jobs.JobsHostedService.AddJobsServices(services); + services.AddHostedService(); + } + else + { + // PDF generation services.AddJsReport(new jsreport.Local.LocalReporting() .UseBinary(jsreport.Binary.JsReportBinary.GetBinary()) .AsUtility() diff --git a/src/Api/build.sh b/src/Api/build.sh index 0f23ebe646..905e69d192 100755 --- a/src/Api/build.sh +++ b/src/Api/build.sh @@ -9,13 +9,10 @@ echo -e "\nBuilding app" echo ".NET Core version $(dotnet --version)" echo "Restore" dotnet restore $DIR/Api.csproj -dotnet restore $DIR/../Jobs/Jobs.csproj echo "Clean" dotnet clean $DIR/Api.csproj -c "Release" -o $DIR/obj/Docker/publish/Api -dotnet clean $DIR/../Jobs/Jobs.csproj -c "Release" -o $DIR/obj/Docker/publish/Jobs echo "Publish" dotnet publish $DIR/Api.csproj -c "Release" -o $DIR/obj/Docker/publish/Api -dotnet publish $DIR/../Jobs/Jobs.csproj -c "Release" -o $DIR/obj/Docker/publish/Jobs echo -e "\nBuilding docker image" docker --version diff --git a/src/Api/entrypoint.sh b/src/Api/entrypoint.sh index 6ae29d4624..19c30c616c 100644 --- a/src/Api/entrypoint.sh +++ b/src/Api/entrypoint.sh @@ -29,19 +29,12 @@ mkhomedir_helper $USERNAME # The rest... -touch /var/log/cron.log -chown $USERNAME:$GROUPNAME /var/log/cron.log chown -R $USERNAME:$GROUPNAME /app -chown -R $USERNAME:$GROUPNAME /jobs mkdir -p /etc/bitwarden/core mkdir -p /etc/bitwarden/logs mkdir -p /etc/bitwarden/ca-certificates chown -R $USERNAME:$GROUPNAME /etc/bitwarden -# Sounds like gosu keeps env when switching, but of course cron does not -env > /etc/environment -cron - cp /etc/bitwarden/ca-certificates/*.crt /usr/local/share/ca-certificates/ >/dev/null 2>&1 \ && update-ca-certificates diff --git a/src/Core/Utilities/ServiceCollectionExtensions.cs b/src/Core/Utilities/ServiceCollectionExtensions.cs index 4e3f54c3d4..d4ba1adb9b 100644 --- a/src/Core/Utilities/ServiceCollectionExtensions.cs +++ b/src/Core/Utilities/ServiceCollectionExtensions.cs @@ -22,7 +22,6 @@ using SqlServerRepos = Bit.Core.Repositories.SqlServer; using System.Threading.Tasks; using TableStorageRepos = Bit.Core.Repositories.TableStorage; using Microsoft.Extensions.DependencyInjection.Extensions; -using System.Collections.Generic; namespace Bit.Core.Utilities { diff --git a/src/Jobs/Jobs.csproj b/src/Jobs/Jobs.csproj deleted file mode 100644 index d176e3234e..0000000000 --- a/src/Jobs/Jobs.csproj +++ /dev/null @@ -1,25 +0,0 @@ - - - - Exe - netcoreapp2.1 - Bit.Jobs - bitwarden-Jobs - - - - - Always - - - - - - - - - - - - - diff --git a/src/Jobs/NoopServer.cs b/src/Jobs/NoopServer.cs deleted file mode 100644 index 39dcc6c39c..0000000000 --- a/src/Jobs/NoopServer.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System.Threading; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Hosting.Server; -using Microsoft.AspNetCore.Http.Features; - -namespace Bit.Jobs -{ - public class NoopServer : IServer - { - public IFeatureCollection Features => new FeatureCollection(); - - public void Dispose() - { } - - public Task StartAsync(IHttpApplication application, CancellationToken cancellationToken) - { - return Task.FromResult(0); - } - - public Task StopAsync(CancellationToken cancellationToken) - { - return Task.FromResult(0); - } - } -} diff --git a/src/Jobs/Program.cs b/src/Jobs/Program.cs deleted file mode 100644 index 2d01f485e1..0000000000 --- a/src/Jobs/Program.cs +++ /dev/null @@ -1,97 +0,0 @@ -using Bit.Core.Services; -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; -using System; -using System.Collections.Generic; -using System.IO; -using System.Threading.Tasks; - -namespace Bit.Jobs -{ - public class Program - { - private static ILicensingService _licensingService; - private static ILogger _logger; - - public static void Main(string[] args) - { - var parameters = ParseParameters(args); - try - { - var host = new WebHostBuilder() - .UseContentRoot(parameters.ContainsKey("d") ? parameters["d"] : Directory.GetCurrentDirectory()) - .UseStartup() - .UseServer(new NoopServer()) - .Build(); - - _logger = host.Services.GetRequiredService>(); - _licensingService = host.Services.GetRequiredService(); - } - catch(Exception e) - { - if(_logger != null) - { - _logger.LogCritical(1, e, "Error while bootstrapping."); - } - throw e; - } - - MainAsync(parameters).Wait(); - } - - private async static Task MainAsync(IDictionary parameters) - { - if(!parameters.ContainsKey("j")) - { - return; - } - - _logger.LogInformation("Starting job {0}.", parameters["j"]); - - try - { - switch(parameters["j"]) - { - case "validate-organizations": - await _licensingService.ValidateOrganizationsAsync(); - break; - case "validate-users-premium": - await _licensingService.ValidateUsersAsync(); - break; - case "refresh-licenses": - // TODO - break; - case "alive": - _logger.LogInformation(DateTime.UtcNow.ToString()); - break; - default: - break; - } - } - catch(Exception e) - { - _logger.LogError(2, e, "Error performing job."); - throw e; - } - - _logger.LogInformation("Finished job {0}.", parameters["j"]); - } - - private static IDictionary ParseParameters(string[] args) - { - var dict = new Dictionary(); - for(var i = 0; i < args.Length; i = i + 2) - { - if(!args[i].StartsWith("-")) - { - continue; - } - - dict.Add(args[i].Substring(1), args[i + 1]); - } - - return dict; - } - } -} diff --git a/src/Jobs/Properties/launchSettings.json b/src/Jobs/Properties/launchSettings.json deleted file mode 100644 index b4d140a0ac..0000000000 --- a/src/Jobs/Properties/launchSettings.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "profiles": { - "Jobs": { - "commandName": "Project", - "launchBrowser": false, - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - }, - "applicationUrl": "http://localhost:4409/" - } - } -} \ No newline at end of file diff --git a/src/Jobs/Startup.cs b/src/Jobs/Startup.cs deleted file mode 100644 index fdbafa2400..0000000000 --- a/src/Jobs/Startup.cs +++ /dev/null @@ -1,74 +0,0 @@ -using System; -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Configuration; -using Bit.Core; -using Bit.Core.Utilities; -using Microsoft.Extensions.Logging; -using Microsoft.AspNetCore.Builder; -using Serilog.Events; - -namespace Bit.Jobs -{ - public class Startup - { - public Startup(IHostingEnvironment env) - { - var builder = new ConfigurationBuilder() - .SetBasePath(env.ContentRootPath) - .AddJsonFile("appsettings.json") - .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true); - - if(env.IsDevelopment()) - { - builder.AddUserSecrets("bitwarden-Jobs"); - } - - builder.AddEnvironmentVariables(); - - Configuration = builder.Build(); - Environment = env; - } - - public IConfigurationRoot Configuration { get; private set; } - public IHostingEnvironment Environment { get; set; } - - public void ConfigureServices(IServiceCollection services) - { - // Options - services.AddOptions(); - - // Settings - var globalSettings = services.AddGlobalSettingsServices(Configuration); - - // Data Protection - services.AddCustomDataProtectionServices(Environment, globalSettings); - - // Repositories - services.AddSqlServerRepositories(globalSettings); - - // Context - services.AddScoped(); - - // Identity - services.AddCustomIdentityServices(globalSettings); - - // Services - services.AddBaseServices(); - services.AddDefaultServices(globalSettings); - } - - public void Configure( - IApplicationBuilder app, - IHostingEnvironment env, - ILoggerFactory loggerFactory, - IApplicationLifetime appLifetime, - GlobalSettings globalSettings) - { - loggerFactory - .AddSerilog(app, env, appLifetime, globalSettings, e => e.Level >= LogEventLevel.Information) - .AddConsole() - .AddDebug(); - } - } -} diff --git a/src/Jobs/appsettings.Production.json b/src/Jobs/appsettings.Production.json deleted file mode 100644 index 9501db8ac9..0000000000 --- a/src/Jobs/appsettings.Production.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "globalSettings": { - "baseServiceUri": { - "vault": "https://vault.bitwarden.com", - "api": "https://api.bitwarden.com", - "identity": "https://identity.bitwarden.com", - "admin": "https://admin.bitwarden.com", - "internalAdmin": "https://admin.bitwarden.com", - "internalIdentity": "https://identity.bitwarden.com", - "internalApi": "https://api.bitwarden.com", - "internalVault": "https://vault.bitwarden.com" - }, - "braintree": { - "production": true - } - } -} diff --git a/src/Jobs/appsettings.json b/src/Jobs/appsettings.json deleted file mode 100644 index f0b699b47c..0000000000 --- a/src/Jobs/appsettings.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "globalSettings": { - "selfHosted": false, - "siteName": "Bitwarden", - "projectName": "Jobs", - "stripeApiKey": "SECRET", - "baseServiceUri": { - "vault": "https://localhost:8080", - "api": "http://localhost:4000", - "identity": "http://localhost:33656", - "admin": "http://localhost:62911", - "internalAdmin": "http://localhost:62911", - "internalIdentity": "http://localhost:33656", - "internalApi": "http://localhost:4000", - "internalVault": "http://localhost:4001" - }, - "sqlServer": { - "connectionString": "SECRET" - }, - "mail": { - "sendGridApiKey": "SECRET", - "replyToEmail": "hello@bitwarden.com" - }, - "identityServer": { - "certificateThumbprint": "SECRET" - }, - "dataProtection": { - "certificateThumbprint": "SECRET" - }, - "storage": { - "connectionString": "SECRET" - }, - "documentDb": { - "uri": "SECRET", - "key": "SECRET" - }, - "sentry": { - "dsn": "SECRET" - }, - "notificationHub": { - "connectionString": "SECRET", - "hubName": "SECRET" - }, - "yubico": { - "clientid": "SECRET", - "key": "SECRET" - }, - "duo": { - "aKey": "SECRET" - }, - "braintree": { - "production": false, - "merchantId": "SECRET", - "publicKey": "SECRET", - "privateKey": "SECRET" - } - } -} diff --git a/src/Jobs/crontab b/src/Jobs/crontab deleted file mode 100644 index f1c07d7a21..0000000000 --- a/src/Jobs/crontab +++ /dev/null @@ -1,5 +0,0 @@ -0 * * * * bitwarden dotnet /jobs/Jobs.dll -d /jobs -j alive >> /var/log/cron.log 2>&1 -0 */6 * * * bitwarden dotnet /jobs/Jobs.dll -d /jobs -j validate-organizations >> /var/log/cron.log 2>&1 -30 */12 * * * bitwarden dotnet /jobs/Jobs.dll -d /jobs -j validate-users-premium >> /var/log/cron.log 2>&1 - -# An empty line is required at the end of this file for a valid cron file. \ No newline at end of file