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