Fixed: Installer hangs during service removal

Fixes #2223
pull/2234/head
Qstick 2 years ago
parent ef20abba7a
commit d93329a3fd

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

Loading…
Cancel
Save