mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2025-04-24 13:57:11 -04:00
Fixed: Close all database connections on shutdown
This commit is contained in:
parent
97f4a2e651
commit
8701e67b1e
3 changed files with 10 additions and 1 deletions
|
@ -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();
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
using System.Data.SQLite;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
@ -6,6 +7,7 @@ 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;
|
||||
|
||||
namespace NzbDrone.Host
|
||||
|
@ -99,6 +101,7 @@ namespace NzbDrone.Host
|
|||
return args;
|
||||
}
|
||||
|
||||
[EventHandleOrder(EventHandleOrder.Last)]
|
||||
public void Handle(ApplicationShutdownRequested message)
|
||||
{
|
||||
if (!_runtimeInfo.IsWindowsService)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SQLite;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
|
@ -99,6 +100,11 @@ namespace NzbDrone.Host
|
|||
Logger.Info(e.Message);
|
||||
LogManager.Configuration = null;
|
||||
}
|
||||
|
||||
// Make sure there are no lingering database connections
|
||||
GC.Collect();
|
||||
GC.WaitForPendingFinalizers();
|
||||
SQLiteConnection.ClearAllPools();
|
||||
}
|
||||
|
||||
public static IHostBuilder CreateConsoleHostBuilder(string[] args, StartupContext context)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue