reduce work done by system info endpoints
This commit is contained in:
parent
5ca1b96c6f
commit
d7a1a87009
|
@ -361,7 +361,7 @@ namespace Emby.Server.Implementations
|
|||
|
||||
protected IAuthService AuthService { get; private set; }
|
||||
|
||||
protected readonly StartupOptions StartupOptions;
|
||||
public StartupOptions StartupOptions { get; private set; }
|
||||
protected readonly string ReleaseAssetFilename;
|
||||
|
||||
internal IPowerManagement PowerManagement { get; private set; }
|
||||
|
@ -1950,6 +1950,21 @@ namespace Emby.Server.Implementations
|
|||
};
|
||||
}
|
||||
|
||||
public async Task<PublicSystemInfo> GetPublicSystemInfo(CancellationToken cancellationToken)
|
||||
{
|
||||
var localAddress = await GetLocalApiUrl(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return new PublicSystemInfo
|
||||
{
|
||||
Version = ApplicationVersion.ToString(),
|
||||
Id = SystemId,
|
||||
OperatingSystem = EnvironmentInfo.OperatingSystem.ToString(),
|
||||
WanAddress = ConnectManager.WanApiAddress,
|
||||
ServerName = FriendlyName,
|
||||
LocalAddress = localAddress
|
||||
};
|
||||
}
|
||||
|
||||
public bool EnableHttps
|
||||
{
|
||||
get
|
||||
|
|
|
@ -41,7 +41,12 @@ namespace Emby.Server.Implementations.EntryPoints
|
|||
}
|
||||
else if (_config.Configuration.IsStartupWizardCompleted)
|
||||
{
|
||||
BrowserLauncher.OpenDashboardPage("index.html", _appHost);
|
||||
var options = ((ApplicationHost)_appHost).StartupOptions;
|
||||
|
||||
if (!options.ContainsOption("-service") && !options.ContainsOption("-nobrowser"))
|
||||
{
|
||||
BrowserLauncher.OpenDashboardPage("index.html", _appHost);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -11,15 +11,12 @@ using MediaBrowser.Model.Extensions;
|
|||
using MediaBrowser.Model.IO;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using MediaBrowser.Model.Net;
|
||||
using System.Threading;
|
||||
|
||||
namespace Emby.Server.Implementations.Networking
|
||||
{
|
||||
public class NetworkManager : INetworkManager
|
||||
{
|
||||
protected ILogger Logger { get; private set; }
|
||||
private DateTime _lastRefresh;
|
||||
private int NetworkCacheMinutes = 720;
|
||||
|
||||
public event EventHandler NetworkChanged;
|
||||
|
||||
|
@ -33,7 +30,6 @@ namespace Emby.Server.Implementations.Networking
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
NetworkCacheMinutes = 15;
|
||||
Logger.ErrorException("Error binding to NetworkAddressChanged event", ex);
|
||||
}
|
||||
|
||||
|
@ -43,7 +39,6 @@ namespace Emby.Server.Implementations.Networking
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
NetworkCacheMinutes = 15;
|
||||
Logger.ErrorException("Error binding to NetworkChange_NetworkAvailabilityChanged event", ex);
|
||||
}
|
||||
}
|
||||
|
@ -51,19 +46,21 @@ namespace Emby.Server.Implementations.Networking
|
|||
private void NetworkChange_NetworkAvailabilityChanged(object sender, NetworkAvailabilityEventArgs e)
|
||||
{
|
||||
Logger.Debug("NetworkAvailabilityChanged");
|
||||
_lastRefresh = DateTime.MinValue;
|
||||
OnNetworkChanged();
|
||||
}
|
||||
|
||||
private void NetworkChange_NetworkAddressChanged(object sender, EventArgs e)
|
||||
{
|
||||
Logger.Debug("NetworkAddressChanged");
|
||||
_lastRefresh = DateTime.MinValue;
|
||||
OnNetworkChanged();
|
||||
}
|
||||
|
||||
private void OnNetworkChanged()
|
||||
{
|
||||
lock (_localIpAddressSyncLock)
|
||||
{
|
||||
_localIpAddresses = null;
|
||||
}
|
||||
if (NetworkChanged != null)
|
||||
{
|
||||
NetworkChanged(this, EventArgs.Empty);
|
||||
|
@ -77,20 +74,16 @@ namespace Emby.Server.Implementations.Networking
|
|||
{
|
||||
lock (_localIpAddressSyncLock)
|
||||
{
|
||||
var forceRefresh = (DateTime.UtcNow - _lastRefresh).TotalMinutes >= NetworkCacheMinutes;
|
||||
|
||||
if (_localIpAddresses == null || forceRefresh)
|
||||
if (_localIpAddresses == null)
|
||||
{
|
||||
var addresses = GetLocalIpAddressesInternal().Result.Select(ToIpAddressInfo).ToList();
|
||||
|
||||
_localIpAddresses = addresses;
|
||||
_lastRefresh = DateTime.UtcNow;
|
||||
|
||||
return addresses;
|
||||
}
|
||||
return _localIpAddresses;
|
||||
}
|
||||
|
||||
return _localIpAddresses;
|
||||
}
|
||||
|
||||
private async Task<List<IPAddress>> GetLocalIpAddressesInternal()
|
||||
|
|
|
@ -151,7 +151,7 @@ namespace Emby.Server.Implementations.Session
|
|||
return SendMessage("LibraryChanged", info, cancellationToken);
|
||||
}
|
||||
|
||||
public Task SendRestartRequiredNotification(SystemInfo info, CancellationToken cancellationToken)
|
||||
public Task SendRestartRequiredNotification(CancellationToken cancellationToken)
|
||||
{
|
||||
return SendMessage("RestartRequired", cancellationToken);
|
||||
}
|
||||
|
|
|
@ -1182,13 +1182,11 @@ namespace Emby.Server.Implementations.Session
|
|||
{
|
||||
var sessions = Sessions.Where(i => i.IsActive && i.SessionController != null).ToList();
|
||||
|
||||
var info = await _appHost.GetSystemInfo(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
var tasks = sessions.Select(session => Task.Run(async () =>
|
||||
{
|
||||
try
|
||||
{
|
||||
await session.SessionController.SendRestartRequiredNotification(info, cancellationToken).ConfigureAwait(false);
|
||||
await session.SessionController.SendRestartRequiredNotification(cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
|
@ -145,12 +145,12 @@ namespace Emby.Server.Implementations.Session
|
|||
/// <param name="info">The information.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task.</returns>
|
||||
public Task SendRestartRequiredNotification(SystemInfo info, CancellationToken cancellationToken)
|
||||
public Task SendRestartRequiredNotification(CancellationToken cancellationToken)
|
||||
{
|
||||
return SendMessagesInternal(new WebSocketMessage<SystemInfo>
|
||||
return SendMessagesInternal(new WebSocketMessage<string>
|
||||
{
|
||||
MessageType = "RestartRequired",
|
||||
Data = info
|
||||
Data = string.Empty
|
||||
|
||||
}, cancellationToken);
|
||||
}
|
||||
|
|
|
@ -172,19 +172,9 @@ namespace MediaBrowser.Api.System
|
|||
|
||||
public async Task<object> Get(GetPublicSystemInfo request)
|
||||
{
|
||||
var result = await _appHost.GetSystemInfo(CancellationToken.None).ConfigureAwait(false);
|
||||
var result = await _appHost.GetPublicSystemInfo(CancellationToken.None).ConfigureAwait(false);
|
||||
|
||||
var publicInfo = new PublicSystemInfo
|
||||
{
|
||||
Id = result.Id,
|
||||
ServerName = result.ServerName,
|
||||
Version = result.Version,
|
||||
LocalAddress = result.LocalAddress,
|
||||
WanAddress = result.WanAddress,
|
||||
OperatingSystem = result.OperatingSystem
|
||||
};
|
||||
|
||||
return ToOptimizedResult(publicInfo);
|
||||
return ToOptimizedResult(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -22,6 +22,8 @@ namespace MediaBrowser.Controller
|
|||
/// <returns>SystemInfo.</returns>
|
||||
Task<SystemInfo> GetSystemInfo(CancellationToken cancellationToken);
|
||||
|
||||
Task<PublicSystemInfo> GetPublicSystemInfo(CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether [supports automatic run at startup].
|
||||
/// </summary>
|
||||
|
|
|
@ -55,10 +55,7 @@ namespace MediaBrowser.Controller.Session
|
|||
/// <summary>
|
||||
/// Sends the restart required message.
|
||||
/// </summary>
|
||||
/// <param name="info">The information.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task.</returns>
|
||||
Task SendRestartRequiredNotification(SystemInfo info, CancellationToken cancellationToken);
|
||||
Task SendRestartRequiredNotification(CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Sends the user data change info.
|
||||
|
|
Loading…
Reference in New Issue
Block a user