option to disable and configure inactive session threshold
This commit is contained in:
parent
8bb44b85d7
commit
e1190d15d6
|
@ -19,6 +19,7 @@ using MediaBrowser.Common.Events;
|
|||
using MediaBrowser.Common.Extensions;
|
||||
using MediaBrowser.Controller;
|
||||
using MediaBrowser.Controller.Authentication;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Devices;
|
||||
using MediaBrowser.Controller.Drawing;
|
||||
using MediaBrowser.Controller.Dto;
|
||||
|
@ -46,6 +47,7 @@ namespace Emby.Server.Implementations.Session
|
|||
public class SessionManager : ISessionManager, IDisposable
|
||||
{
|
||||
private readonly IUserDataManager _userDataManager;
|
||||
private readonly IServerConfigurationManager _config;
|
||||
private readonly ILogger<SessionManager> _logger;
|
||||
private readonly IEventManager _eventManager;
|
||||
private readonly ILibraryManager _libraryManager;
|
||||
|
@ -65,8 +67,6 @@ namespace Emby.Server.Implementations.Session
|
|||
private Timer _idleTimer;
|
||||
private Timer _inactiveTimer;
|
||||
|
||||
private int inactiveMinutesThreshold = 10;
|
||||
|
||||
private DtoOptions _itemInfoDtoOptions;
|
||||
private bool _disposed = false;
|
||||
|
||||
|
@ -74,6 +74,7 @@ namespace Emby.Server.Implementations.Session
|
|||
ILogger<SessionManager> logger,
|
||||
IEventManager eventManager,
|
||||
IUserDataManager userDataManager,
|
||||
IServerConfigurationManager config,
|
||||
ILibraryManager libraryManager,
|
||||
IUserManager userManager,
|
||||
IMusicManager musicManager,
|
||||
|
@ -86,6 +87,7 @@ namespace Emby.Server.Implementations.Session
|
|||
_logger = logger;
|
||||
_eventManager = eventManager;
|
||||
_userDataManager = userDataManager;
|
||||
_config = config;
|
||||
_libraryManager = libraryManager;
|
||||
_userManager = userManager;
|
||||
_musicManager = musicManager;
|
||||
|
@ -581,8 +583,16 @@ namespace Emby.Server.Implementations.Session
|
|||
private void StartCheckTimers()
|
||||
{
|
||||
_idleTimer ??= new Timer(CheckForIdlePlayback, null, TimeSpan.FromMinutes(5), TimeSpan.FromMinutes(5));
|
||||
|
||||
if (_config.Configuration.InactiveSessionThreshold > 0)
|
||||
{
|
||||
_inactiveTimer ??= new Timer(CheckForInactiveSteams, null, TimeSpan.FromMinutes(1), TimeSpan.FromMinutes(1));
|
||||
}
|
||||
else
|
||||
{
|
||||
StopInactiveCheckTimer();
|
||||
}
|
||||
}
|
||||
|
||||
private void StopIdleCheckTimer()
|
||||
{
|
||||
|
@ -652,11 +662,11 @@ namespace Emby.Server.Implementations.Session
|
|||
|
||||
if (pausedSessions.Count > 0)
|
||||
{
|
||||
var inactiveSessions = Sessions.Where(i => (DateTime.UtcNow - i.LastPausedDate).Value.TotalMinutes > inactiveMinutesThreshold).ToList();
|
||||
var inactiveSessions = pausedSessions.Where(i => (DateTime.UtcNow - i.LastPausedDate).Value.TotalMinutes > _config.Configuration.InactiveSessionThreshold).ToList();
|
||||
|
||||
foreach (var session in inactiveSessions)
|
||||
{
|
||||
_logger.LogDebug("Session {0} has been inactive for {1} minutes. Stopping it.", session.Id, inactiveMinutesThreshold);
|
||||
_logger.LogDebug("Session {0} has been inactive for {1} minutes. Stopping it.", session.Id, _config.Configuration.InactiveSessionThreshold);
|
||||
|
||||
try
|
||||
{
|
||||
|
|
|
@ -157,6 +157,12 @@ namespace MediaBrowser.Model.Configuration
|
|||
/// <value>The remaining time in minutes.</value>
|
||||
public int MaxAudiobookResume { get; set; } = 5;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the threshold in minutes after a inactive session gets closed automatically.
|
||||
/// </summary>
|
||||
/// <value>The close inactive session threshold in minutes.</value>
|
||||
public int InactiveSessionThreshold { get; set; } = 10;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the delay in seconds that we will wait after a file system change to try and discover what has been added/removed
|
||||
/// Some delay is necessary with some items because their creation is not atomic. It involves the creation of several
|
||||
|
|
Loading…
Reference in New Issue
Block a user