Hangfire now dies gracefully when using CTRL+C rather than Stop button in Rider. Implemented one stream method for testing. Regenerated a few migrations due to oversight in index not taking account of library.
This commit is contained in:
parent
126fb57f4d
commit
9035b6cc4e
17 changed files with 156 additions and 41 deletions
|
|
@ -52,6 +52,7 @@ namespace API.Services
|
|||
return chapter;
|
||||
}
|
||||
|
||||
|
||||
public void Cleanup()
|
||||
{
|
||||
_logger.LogInformation("Performing cleanup of Cache directory");
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ namespace API.Services
|
|||
private readonly ICleanupService _cleanupService;
|
||||
private readonly IDirectoryService _directoryService;
|
||||
|
||||
public BackgroundJobServer Client => new BackgroundJobServer();
|
||||
public static BackgroundJobServer Client => new BackgroundJobServer();
|
||||
// new BackgroundJobServerOptions()
|
||||
// {
|
||||
// WorkerCount = 1
|
||||
|
|
@ -39,16 +39,14 @@ namespace API.Services
|
|||
_backupService = backupService;
|
||||
_cleanupService = cleanupService;
|
||||
_directoryService = directoryService;
|
||||
|
||||
//Hangfire.RecurringJob.RemoveIfExists();
|
||||
|
||||
ScheduleTasks();
|
||||
//JobStorage.Current.GetMonitoringApi().EnqueuedJobs()
|
||||
|
||||
}
|
||||
|
||||
public void ScheduleTasks()
|
||||
{
|
||||
_logger.LogInformation("Scheduling reoccurring tasks");
|
||||
|
||||
string setting = null;
|
||||
setting = Task.Run(() => _unitOfWork.SettingsRepository.GetSettingAsync(ServerSettingKey.TaskScan)).Result.Value;
|
||||
if (setting != null)
|
||||
|
|
|
|||
|
|
@ -3,11 +3,13 @@ using System.Collections.Generic;
|
|||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using API.Entities.Enums;
|
||||
using API.Extensions;
|
||||
using API.Interfaces;
|
||||
using API.Interfaces.Services;
|
||||
using Hangfire;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
|
|
@ -57,6 +59,7 @@ namespace API.Services.Tasks
|
|||
return files;
|
||||
}
|
||||
|
||||
[AutomaticRetry(Attempts = 3, LogEvents = false, OnAttemptsExceeded = AttemptsExceededAction.Fail)]
|
||||
public void BackupDatabase()
|
||||
{
|
||||
_logger.LogInformation("Beginning backup of Database at {BackupTime}", DateTime.Now);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using System.IO;
|
||||
using API.Interfaces.Services;
|
||||
using Hangfire;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace API.Services.Tasks
|
||||
|
|
@ -20,6 +21,7 @@ namespace API.Services.Tasks
|
|||
_logger = logger;
|
||||
}
|
||||
|
||||
[AutomaticRetry(Attempts = 3, LogEvents = false, OnAttemptsExceeded = AttemptsExceededAction.Fail)]
|
||||
public void Cleanup()
|
||||
{
|
||||
_logger.LogInformation("Cleaning temp directory");
|
||||
|
|
|
|||
|
|
@ -33,7 +33,8 @@ namespace API.Services.Tasks
|
|||
_metadataService = metadataService;
|
||||
}
|
||||
|
||||
[DisableConcurrentExecution(timeoutInSeconds: 120)]
|
||||
[DisableConcurrentExecution(timeoutInSeconds: 5)]
|
||||
[AutomaticRetry(Attempts = 0, LogEvents = false, OnAttemptsExceeded = AttemptsExceededAction.Delete)]
|
||||
public void ScanLibraries()
|
||||
{
|
||||
var libraries = Task.Run(() => _unitOfWork.LibraryRepository.GetLibrariesAsync()).Result.ToList();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue