|
|
|
@ -14,6 +14,7 @@ using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using Microsoft.Extensions.Hosting;
|
|
|
|
|
using Microsoft.Extensions.Hosting.WindowsServices;
|
|
|
|
|
using NLog;
|
|
|
|
|
using Npgsql;
|
|
|
|
|
using NzbDrone.Common.Composition.Extensions;
|
|
|
|
|
using NzbDrone.Common.Disk;
|
|
|
|
|
using NzbDrone.Common.EnvironmentInfo;
|
|
|
|
@ -55,6 +56,7 @@ namespace NzbDrone.Host
|
|
|
|
|
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
|
|
|
|
|
|
|
|
|
|
var appMode = GetApplicationMode(startupContext);
|
|
|
|
|
var config = GetConfiguration(startupContext);
|
|
|
|
|
|
|
|
|
|
switch (appMode)
|
|
|
|
|
{
|
|
|
|
@ -83,12 +85,22 @@ namespace NzbDrone.Host
|
|
|
|
|
// Utility mode
|
|
|
|
|
default:
|
|
|
|
|
{
|
|
|
|
|
new Container(rules => rules.WithNzbDroneRules())
|
|
|
|
|
.AutoAddServices(ASSEMBLIES)
|
|
|
|
|
.AddNzbDroneLogger()
|
|
|
|
|
.AddStartupContext(startupContext)
|
|
|
|
|
.Resolve<UtilityModeRouter>()
|
|
|
|
|
.Route(appMode);
|
|
|
|
|
new HostBuilder()
|
|
|
|
|
.UseServiceProviderFactory(new DryIocServiceProviderFactory(new Container(rules => rules.WithNzbDroneRules())))
|
|
|
|
|
.ConfigureContainer<IContainer>(c =>
|
|
|
|
|
{
|
|
|
|
|
c.AutoAddServices(Bootstrap.ASSEMBLIES)
|
|
|
|
|
.AddNzbDroneLogger()
|
|
|
|
|
.AddDatabase()
|
|
|
|
|
.AddStartupContext(startupContext)
|
|
|
|
|
.Resolve<UtilityModeRouter>()
|
|
|
|
|
.Route(appMode);
|
|
|
|
|
})
|
|
|
|
|
.ConfigureServices(services =>
|
|
|
|
|
{
|
|
|
|
|
services.Configure<PostgresOptions>(config.GetSection("Readarr:Postgres"));
|
|
|
|
|
}).Build();
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -111,6 +123,7 @@ namespace NzbDrone.Host
|
|
|
|
|
GC.Collect();
|
|
|
|
|
GC.WaitForPendingFinalizers();
|
|
|
|
|
SQLiteConnection.ClearAllPools();
|
|
|
|
|
NpgsqlConnection.ClearAllPools();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static IHostBuilder CreateConsoleHostBuilder(string[] args, StartupContext context)
|
|
|
|
|