rdt-client/server/RdtClient.Service/Services/Startup.cs
Roger Far d16e7f0c88 Changed the Aria2 updates to be done in the main TorrentRunner loop instead of each downloader making their own connections.
Added checks if Aria2 links actually got added.
Improved debug messages and set Microsoft message to Warning.
Abstracted the RealDebrid client into a ITorrentClient.
Add retry mechanism for server errors from RealDebrid.
2021-10-27 14:55:46 -06:00

32 lines
859 B
C#

using System;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
namespace RdtClient.Service.Services
{
public class Startup : IHostedService
{
private readonly IServiceProvider _serviceProvider;
public Startup(IServiceProvider serviceProvider)
{
_serviceProvider = serviceProvider;
}
public async Task StartAsync(CancellationToken cancellationToken)
{
using var scope = _serviceProvider.CreateScope();
var settings = scope.ServiceProvider.GetRequiredService<Settings>();
await settings.ResetCache();
await settings.Clean();
}
public Task StopAsync(CancellationToken cancellationToken) => Task.CompletedTask;
}
}