From 9662b9caf9441ad3ab89b6d3edd8f1efd7008e2b Mon Sep 17 00:00:00 2001 From: StanR Date: Mon, 1 Jul 2024 14:03:37 +0500 Subject: [PATCH] AAdd hangfire logs, DisableConcurrentExecution --- backend/Mutualify/Jobs/UserRelationsUpdateJob.cs | 4 +++- backend/Mutualify/Jobs/UserUpdateJob.cs | 2 ++ backend/Mutualify/Program.cs | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/backend/Mutualify/Jobs/UserRelationsUpdateJob.cs b/backend/Mutualify/Jobs/UserRelationsUpdateJob.cs index 4f25a93..b60d623 100644 --- a/backend/Mutualify/Jobs/UserRelationsUpdateJob.cs +++ b/backend/Mutualify/Jobs/UserRelationsUpdateJob.cs @@ -1,4 +1,5 @@ -using Hangfire.Server; +using Hangfire; +using Hangfire.Server; using Microsoft.EntityFrameworkCore; using Mutualify.Database; using Mutualify.Jobs.Interfaces; @@ -26,6 +27,7 @@ public UserRelationsUpdateJob(IUsersService usersService, IRelationsService rela _databaseContext = databaseContext; } + [DisableConcurrentExecution(timeoutInSeconds: 60 * 60 * 24)] public async Task Run(PerformContext context, CancellationToken token) { var jobId = context.BackgroundJob.Id; diff --git a/backend/Mutualify/Jobs/UserUpdateJob.cs b/backend/Mutualify/Jobs/UserUpdateJob.cs index a2ddfd6..224955a 100644 --- a/backend/Mutualify/Jobs/UserUpdateJob.cs +++ b/backend/Mutualify/Jobs/UserUpdateJob.cs @@ -1,4 +1,5 @@  +using Hangfire; using Hangfire.Server; using Microsoft.EntityFrameworkCore; using Mutualify.Database; @@ -25,6 +26,7 @@ public UserUpdateJob(IUsersService usersService, ILogger logger, _databaseContext = databaseContext; } + [DisableConcurrentExecution(timeoutInSeconds: 60 * 60 * 24)] public async Task Run(PerformContext context, CancellationToken token) { var jobId = context.BackgroundJob.Id; diff --git a/backend/Mutualify/Program.cs b/backend/Mutualify/Program.cs index bc6e18a..0549379 100644 --- a/backend/Mutualify/Program.cs +++ b/backend/Mutualify/Program.cs @@ -144,6 +144,7 @@ static Task UnauthorizedRedirect(RedirectContext co x.SetDataCompatibilityLevel(CompatibilityLevel.Version_180) .UseSimpleAssemblyNameTypeSerializer() .UseRecommendedSerializerSettings() + .UseSerilogLogProvider() .UsePostgreSqlStorage(options => { options.UseConnectionFactory(new NpgsqlConnectionFactory(connectionString.ConnectionString,