mirror of
https://github.com/Kareadita/Kavita.git
synced 2025-07-09 03:04:19 -04:00
For the time out on tasks, I'm going to only use Hangfire scheduled tasks on prod.
This commit is contained in:
parent
fad4ca4414
commit
55cd0c5fe5
@ -6,6 +6,8 @@ using API.Helpers.Converters;
|
|||||||
using API.Interfaces;
|
using API.Interfaces;
|
||||||
using API.Interfaces.Services;
|
using API.Interfaces.Services;
|
||||||
using Hangfire;
|
using Hangfire;
|
||||||
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace API.Services
|
namespace API.Services
|
||||||
@ -29,7 +31,7 @@ namespace API.Services
|
|||||||
|
|
||||||
public TaskScheduler(ICacheService cacheService, ILogger<TaskScheduler> logger, IScannerService scannerService,
|
public TaskScheduler(ICacheService cacheService, ILogger<TaskScheduler> logger, IScannerService scannerService,
|
||||||
IUnitOfWork unitOfWork, IMetadataService metadataService, IBackupService backupService, ICleanupService cleanupService,
|
IUnitOfWork unitOfWork, IMetadataService metadataService, IBackupService backupService, ICleanupService cleanupService,
|
||||||
IDirectoryService directoryService)
|
IDirectoryService directoryService, IWebHostEnvironment env)
|
||||||
{
|
{
|
||||||
_cacheService = cacheService;
|
_cacheService = cacheService;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
@ -39,8 +41,18 @@ namespace API.Services
|
|||||||
_backupService = backupService;
|
_backupService = backupService;
|
||||||
_cleanupService = cleanupService;
|
_cleanupService = cleanupService;
|
||||||
_directoryService = directoryService;
|
_directoryService = directoryService;
|
||||||
|
|
||||||
|
if (!env.IsDevelopment())
|
||||||
|
{
|
||||||
|
ScheduleTasks();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
RecurringJob.RemoveIfExists("scan-libraries");
|
||||||
|
RecurringJob.RemoveIfExists("backup");
|
||||||
|
RecurringJob.RemoveIfExists("cleanup");
|
||||||
|
}
|
||||||
|
|
||||||
ScheduleTasks();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ScheduleTasks()
|
public void ScheduleTasks()
|
||||||
@ -78,8 +90,7 @@ namespace API.Services
|
|||||||
|
|
||||||
_logger.LogInformation("Enqueuing library scan for: {LibraryId}", libraryId);
|
_logger.LogInformation("Enqueuing library scan for: {LibraryId}", libraryId);
|
||||||
BackgroundJob.Enqueue(() => _scannerService.ScanLibrary(libraryId, forceUpdate));
|
BackgroundJob.Enqueue(() => _scannerService.ScanLibrary(libraryId, forceUpdate));
|
||||||
//BackgroundJob.Enqueue(() => _cleanupService.Cleanup()); // When we do a scan, force cache to re-unpack in case page numbers change
|
BackgroundJob.Enqueue(() => _cleanupService.Cleanup()); // When we do a scan, force cache to re-unpack in case page numbers change
|
||||||
RecurringJob.Trigger("cleanup"); // TODO: Alternate way to trigger jobs. Test this out and see if we should switch.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CleanupChapters(int[] chapterIds)
|
public void CleanupChapters(int[] chapterIds)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user