mirror of
https://github.com/Kareadita/Kavita.git
synced 2025-07-09 03:04:19 -04:00
Can't figure out how to implement StartupTask
This commit is contained in:
parent
e60d84a2c8
commit
4c6758b9b0
@ -43,10 +43,8 @@ namespace API
|
|||||||
logger.LogError(ex, "An error occurred during migration");
|
logger.LogError(ex, "An error occurred during migration");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load all tasks from DI (TODO: This is not working - WarmupServicesStartupTask is Null)
|
// Load all tasks from DI and initialize them (TODO: This is not working - WarmupServicesStartupTask is Null)
|
||||||
var startupTasks = host.Services.GetServices<WarmupServicesStartupTask>();
|
var startupTasks = host.Services.GetServices<WarmupServicesStartupTask>();
|
||||||
|
|
||||||
// Execute all the tasks
|
|
||||||
foreach (var startupTask in startupTasks)
|
foreach (var startupTask in startupTasks)
|
||||||
{
|
{
|
||||||
await startupTask.ExecuteAsync();
|
await startupTask.ExecuteAsync();
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.IO.Compression;
|
using System.IO.Compression;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using API.Data;
|
|
||||||
using API.Extensions;
|
using API.Extensions;
|
||||||
|
using API.Interfaces.Services;
|
||||||
using API.Middleware;
|
using API.Middleware;
|
||||||
using API.Services;
|
using API.Services;
|
||||||
using Hangfire;
|
using Hangfire;
|
||||||
@ -18,9 +18,7 @@ using Microsoft.Extensions.Configuration;
|
|||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using Microsoft.OpenApi.Models;
|
using Microsoft.OpenApi.Models;
|
||||||
using IApplicationLifetime = Microsoft.AspNetCore.Hosting.IApplicationLifetime;
|
|
||||||
|
|
||||||
namespace API
|
namespace API
|
||||||
{
|
{
|
||||||
@ -85,10 +83,8 @@ namespace API
|
|||||||
// Add the processing server as IHostedService
|
// Add the processing server as IHostedService
|
||||||
services.AddHangfireServer();
|
services.AddHangfireServer();
|
||||||
|
|
||||||
|
//services.AddStartupTask<WarmupServicesStartupTask>(services).
|
||||||
// services
|
services.AddTransient<IStartupTask, WarmupServicesStartupTask>().TryAddSingleton(services);
|
||||||
// .AddStartupTask<WarmupServicesStartupTask>()
|
|
||||||
// //.TryAddSingleton(services);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user