mirror of
https://github.com/Radarr/Radarr.git
synced 2026-04-15 21:05:48 -04:00
Fixed: Close all database connections on shutdown
This commit is contained in:
@@ -14,8 +14,8 @@ using NzbDrone.Core.Datastore;
|
||||
using NzbDrone.Core.Datastore.Extensions;
|
||||
using NzbDrone.Core.Lifecycle;
|
||||
using NzbDrone.Core.Messaging.Events;
|
||||
using NzbDrone.Host;
|
||||
using NzbDrone.Test.Common;
|
||||
using Radarr.Host;
|
||||
|
||||
namespace NzbDrone.Common.Test
|
||||
{
|
||||
|
||||
@@ -2,14 +2,12 @@ using System;
|
||||
using System.IO;
|
||||
using System.Net.Sockets;
|
||||
using Microsoft.AspNetCore.Connections;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using NLog;
|
||||
using NzbDrone.Common.EnvironmentInfo;
|
||||
using NzbDrone.Common.Exceptions;
|
||||
using NzbDrone.Common.Instrumentation;
|
||||
using Radarr.Host;
|
||||
using Radarr.Host.AccessControl;
|
||||
using NzbDrone.Host;
|
||||
using NzbDrone.Host.AccessControl;
|
||||
|
||||
namespace NzbDrone.Console
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Data.SQLite;
|
||||
using NLog;
|
||||
@@ -128,7 +128,7 @@ namespace NzbDrone.Core.Instrumentation
|
||||
private void WriteSqliteLog(Log log, string connectionString)
|
||||
{
|
||||
using (var connection =
|
||||
SQLiteFactory.Instance.CreateConnection())
|
||||
new SQLiteConnection(_connectionStringFactory.LogDbConnectionString).OpenAndReturn())
|
||||
{
|
||||
connection.ConnectionString = connectionString;
|
||||
connection.Open();
|
||||
|
||||
@@ -20,9 +20,9 @@ using NzbDrone.Core.Indexers;
|
||||
using NzbDrone.Core.Lifecycle;
|
||||
using NzbDrone.Core.Messaging.Commands;
|
||||
using NzbDrone.Core.Messaging.Events;
|
||||
using NzbDrone.Host;
|
||||
using NzbDrone.SignalR;
|
||||
using NzbDrone.Test.Common;
|
||||
using Radarr.Host;
|
||||
using IServiceProvider = System.IServiceProvider;
|
||||
|
||||
namespace NzbDrone.App.Test
|
||||
|
||||
@@ -3,8 +3,8 @@ using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common.Model;
|
||||
using NzbDrone.Common.Processes;
|
||||
using NzbDrone.Host;
|
||||
using NzbDrone.Test.Common;
|
||||
using Radarr.Host;
|
||||
|
||||
namespace NzbDrone.App.Test
|
||||
{
|
||||
|
||||
@@ -3,8 +3,8 @@ using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.EnvironmentInfo;
|
||||
using NzbDrone.Common.Processes;
|
||||
using NzbDrone.Host;
|
||||
using NzbDrone.Test.Common;
|
||||
using Radarr.Host;
|
||||
|
||||
namespace NzbDrone.App.Test
|
||||
{
|
||||
|
||||
@@ -5,7 +5,7 @@ using NLog;
|
||||
using NzbDrone.Common.EnvironmentInfo;
|
||||
using NzbDrone.Core.Configuration;
|
||||
|
||||
namespace Radarr.Host.AccessControl
|
||||
namespace NzbDrone.Host.AccessControl
|
||||
{
|
||||
public interface IFirewallAdapter
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using NzbDrone.Common.EnvironmentInfo;
|
||||
|
||||
namespace Radarr.Host.AccessControl
|
||||
namespace NzbDrone.Host.AccessControl
|
||||
{
|
||||
public interface IRemoteAccessAdapter
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using NzbDrone.Common.Exceptions;
|
||||
|
||||
namespace Radarr.Host.AccessControl
|
||||
namespace NzbDrone.Host.AccessControl
|
||||
{
|
||||
public class RemoteAccessException : NzbDroneException
|
||||
{
|
||||
|
||||
@@ -6,8 +6,8 @@ using NzbDrone.Common.EnvironmentInfo;
|
||||
using NzbDrone.Common.Processes;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.Lifecycle;
|
||||
using NzbDrone.Core.Messaging;
|
||||
using NzbDrone.Core.Messaging.Events;
|
||||
using Radarr.Host;
|
||||
|
||||
namespace NzbDrone.Host
|
||||
{
|
||||
@@ -100,6 +100,7 @@ namespace NzbDrone.Host
|
||||
return args;
|
||||
}
|
||||
|
||||
[EventHandleOrder(EventHandleOrder.Last)]
|
||||
public void Handle(ApplicationShutdownRequested message)
|
||||
{
|
||||
if (!_runtimeInfo.IsWindowsService)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Radarr.Host
|
||||
namespace NzbDrone.Host
|
||||
{
|
||||
public enum ApplicationModes
|
||||
{
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SQLite;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
@@ -14,6 +15,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.EnvironmentInfo;
|
||||
using NzbDrone.Common.Exceptions;
|
||||
@@ -22,10 +24,9 @@ using NzbDrone.Common.Instrumentation;
|
||||
using NzbDrone.Common.Instrumentation.Extensions;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.Datastore.Extensions;
|
||||
using NzbDrone.Host;
|
||||
using PostgresOptions = NzbDrone.Core.Datastore.PostgresOptions;
|
||||
|
||||
namespace Radarr.Host
|
||||
namespace NzbDrone.Host
|
||||
{
|
||||
public static class Bootstrap
|
||||
{
|
||||
@@ -111,6 +112,12 @@ namespace Radarr.Host
|
||||
Logger.Info(e.Message);
|
||||
LogManager.Configuration = null;
|
||||
}
|
||||
|
||||
// Make sure there are no lingering database connections
|
||||
GC.Collect();
|
||||
GC.WaitForPendingFinalizers();
|
||||
SQLiteConnection.ClearAllPools();
|
||||
NpgsqlConnection.ClearAllPools();
|
||||
}
|
||||
|
||||
public static IHostBuilder CreateConsoleHostBuilder(string[] args, StartupContext context)
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
using System;
|
||||
using System;
|
||||
using NLog;
|
||||
using NzbDrone.Common.EnvironmentInfo;
|
||||
using NzbDrone.Common.Processes;
|
||||
using NzbDrone.Core.Configuration;
|
||||
|
||||
namespace Radarr.Host
|
||||
namespace NzbDrone.Host
|
||||
{
|
||||
public interface IBrowserService
|
||||
{
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NLog;
|
||||
using NzbDrone.Common.Processes;
|
||||
|
||||
namespace Radarr.Host
|
||||
namespace NzbDrone.Host
|
||||
{
|
||||
public interface ISingleInstancePolicy
|
||||
{
|
||||
|
||||
@@ -19,11 +19,10 @@ using NzbDrone.Common.Serializer;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.Datastore;
|
||||
using NzbDrone.Core.Instrumentation;
|
||||
using NzbDrone.Host.AccessControl;
|
||||
using NzbDrone.Http.Authentication;
|
||||
using NzbDrone.SignalR;
|
||||
using Radarr.Api.V3.System;
|
||||
using Radarr.Host;
|
||||
using Radarr.Host.AccessControl;
|
||||
using Radarr.Http;
|
||||
using Radarr.Http.Authentication;
|
||||
using Radarr.Http.ErrorManagement;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using System;
|
||||
|
||||
namespace Radarr.Host
|
||||
namespace NzbDrone.Host
|
||||
{
|
||||
public class TerminateApplicationException : ApplicationException
|
||||
{
|
||||
|
||||
@@ -2,10 +2,10 @@ using NLog;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.EnvironmentInfo;
|
||||
using NzbDrone.Common.Processes;
|
||||
using Radarr.Host.AccessControl;
|
||||
using NzbDrone.Host.AccessControl;
|
||||
using IServiceProvider = NzbDrone.Common.IServiceProvider;
|
||||
|
||||
namespace Radarr.Host
|
||||
namespace NzbDrone.Host
|
||||
{
|
||||
public interface IUtilityModeRouter
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user