mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-07-05 13:23:03 +02:00
Merge pull request #9191 from barronpm/applicationhost-cleanup1
This commit is contained in:
commit
58b3945805
|
@ -11,7 +11,6 @@ using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using System.Security.Cryptography.X509Certificates;
|
using System.Security.Cryptography.X509Certificates;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
@ -113,15 +112,11 @@ namespace Emby.Server.Implementations
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class ApplicationHost : IServerApplicationHost, IAsyncDisposable, IDisposable
|
public abstract class ApplicationHost : IServerApplicationHost, IAsyncDisposable, IDisposable
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// The environment variable prefixes to log at server startup.
|
|
||||||
/// </summary>
|
|
||||||
private static readonly string[] _relevantEnvVarPrefixes = { "JELLYFIN_", "DOTNET_", "ASPNETCORE_" };
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The disposable parts.
|
/// The disposable parts.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly ConcurrentDictionary<IDisposable, byte> _disposableParts = new();
|
private readonly ConcurrentDictionary<IDisposable, byte> _disposableParts = new();
|
||||||
|
private readonly DeviceId _deviceId;
|
||||||
|
|
||||||
private readonly IFileSystem _fileSystemManager;
|
private readonly IFileSystem _fileSystemManager;
|
||||||
private readonly IConfiguration _startupConfig;
|
private readonly IConfiguration _startupConfig;
|
||||||
|
@ -130,7 +125,6 @@ namespace Emby.Server.Implementations
|
||||||
private readonly IPluginManager _pluginManager;
|
private readonly IPluginManager _pluginManager;
|
||||||
|
|
||||||
private List<Type> _creatingInstances;
|
private List<Type> _creatingInstances;
|
||||||
private IMediaEncoder _mediaEncoder;
|
|
||||||
private ISessionManager _sessionManager;
|
private ISessionManager _sessionManager;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -139,8 +133,6 @@ namespace Emby.Server.Implementations
|
||||||
/// <value>All concrete types.</value>
|
/// <value>All concrete types.</value>
|
||||||
private Type[] _allConcreteTypes;
|
private Type[] _allConcreteTypes;
|
||||||
|
|
||||||
private DeviceId _deviceId;
|
|
||||||
|
|
||||||
private bool _disposed = false;
|
private bool _disposed = false;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -164,6 +156,7 @@ namespace Emby.Server.Implementations
|
||||||
|
|
||||||
Logger = LoggerFactory.CreateLogger<ApplicationHost>();
|
Logger = LoggerFactory.CreateLogger<ApplicationHost>();
|
||||||
_fileSystemManager.AddShortcutHandler(new MbLinkShortcutHandler(_fileSystemManager));
|
_fileSystemManager.AddShortcutHandler(new MbLinkShortcutHandler(_fileSystemManager));
|
||||||
|
_deviceId = new DeviceId(ApplicationPaths, LoggerFactory);
|
||||||
|
|
||||||
ApplicationVersion = typeof(ApplicationHost).Assembly.GetName().Version;
|
ApplicationVersion = typeof(ApplicationHost).Assembly.GetName().Version;
|
||||||
ApplicationVersionString = ApplicationVersion.ToString(3);
|
ApplicationVersionString = ApplicationVersion.ToString(3);
|
||||||
|
@ -191,23 +184,9 @@ namespace Emby.Server.Implementations
|
||||||
|
|
||||||
public bool CoreStartupHasCompleted { get; private set; }
|
public bool CoreStartupHasCompleted { get; private set; }
|
||||||
|
|
||||||
public virtual bool CanLaunchWebBrowser
|
public virtual bool CanLaunchWebBrowser => Environment.UserInteractive
|
||||||
{
|
&& !_startupOptions.IsService
|
||||||
get
|
&& (OperatingSystem.IsWindows() || OperatingSystem.IsMacOS());
|
||||||
{
|
|
||||||
if (!Environment.UserInteractive)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_startupOptions.IsService)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return OperatingSystem.IsWindows() || OperatingSystem.IsMacOS();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the <see cref="INetworkManager"/> singleton instance.
|
/// Gets the <see cref="INetworkManager"/> singleton instance.
|
||||||
|
@ -284,15 +263,7 @@ namespace Emby.Server.Implementations
|
||||||
/// <value>The application name.</value>
|
/// <value>The application name.</value>
|
||||||
public string ApplicationProductName { get; } = FileVersionInfo.GetVersionInfo(Assembly.GetEntryAssembly().Location).ProductName;
|
public string ApplicationProductName { get; } = FileVersionInfo.GetVersionInfo(Assembly.GetEntryAssembly().Location).ProductName;
|
||||||
|
|
||||||
public string SystemId
|
public string SystemId => _deviceId.Value;
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
_deviceId ??= new DeviceId(ApplicationPaths, LoggerFactory);
|
|
||||||
|
|
||||||
return _deviceId.Value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public string Name => ApplicationProductName;
|
public string Name => ApplicationProductName;
|
||||||
|
@ -445,7 +416,7 @@ namespace Emby.Server.Implementations
|
||||||
ConfigurationManager.ConfigurationUpdated += OnConfigurationUpdated;
|
ConfigurationManager.ConfigurationUpdated += OnConfigurationUpdated;
|
||||||
ConfigurationManager.NamedConfigurationUpdated += OnConfigurationUpdated;
|
ConfigurationManager.NamedConfigurationUpdated += OnConfigurationUpdated;
|
||||||
|
|
||||||
_mediaEncoder.SetFFmpegPath();
|
Resolve<IMediaEncoder>().SetFFmpegPath();
|
||||||
|
|
||||||
Logger.LogInformation("ServerId: {ServerId}", SystemId);
|
Logger.LogInformation("ServerId: {ServerId}", SystemId);
|
||||||
|
|
||||||
|
@ -655,7 +626,6 @@ namespace Emby.Server.Implementations
|
||||||
var localizationManager = (LocalizationManager)Resolve<ILocalizationManager>();
|
var localizationManager = (LocalizationManager)Resolve<ILocalizationManager>();
|
||||||
await localizationManager.LoadAll().ConfigureAwait(false);
|
await localizationManager.LoadAll().ConfigureAwait(false);
|
||||||
|
|
||||||
_mediaEncoder = Resolve<IMediaEncoder>();
|
|
||||||
_sessionManager = Resolve<ISessionManager>();
|
_sessionManager = Resolve<ISessionManager>();
|
||||||
|
|
||||||
SetStaticProperties();
|
SetStaticProperties();
|
||||||
|
@ -666,36 +636,6 @@ namespace Emby.Server.Implementations
|
||||||
FindParts();
|
FindParts();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void LogEnvironmentInfo(ILogger logger, IApplicationPaths appPaths)
|
|
||||||
{
|
|
||||||
// Distinct these to prevent users from reporting problems that aren't actually problems
|
|
||||||
var commandLineArgs = Environment
|
|
||||||
.GetCommandLineArgs()
|
|
||||||
.Distinct();
|
|
||||||
|
|
||||||
// Get all relevant environment variables
|
|
||||||
var allEnvVars = Environment.GetEnvironmentVariables();
|
|
||||||
var relevantEnvVars = new Dictionary<object, object>();
|
|
||||||
foreach (var key in allEnvVars.Keys)
|
|
||||||
{
|
|
||||||
if (_relevantEnvVarPrefixes.Any(prefix => key.ToString().StartsWith(prefix, StringComparison.OrdinalIgnoreCase)))
|
|
||||||
{
|
|
||||||
relevantEnvVars.Add(key, allEnvVars[key]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.LogInformation("Environment Variables: {EnvVars}", relevantEnvVars);
|
|
||||||
logger.LogInformation("Arguments: {Args}", commandLineArgs);
|
|
||||||
logger.LogInformation("Operating system: {OS}", RuntimeInformation.OSDescription);
|
|
||||||
logger.LogInformation("Architecture: {Architecture}", RuntimeInformation.OSArchitecture);
|
|
||||||
logger.LogInformation("64-Bit Process: {Is64Bit}", Environment.Is64BitProcess);
|
|
||||||
logger.LogInformation("User Interactive: {IsUserInteractive}", Environment.UserInteractive);
|
|
||||||
logger.LogInformation("Processor count: {ProcessorCount}", Environment.ProcessorCount);
|
|
||||||
logger.LogInformation("Program data path: {ProgramDataPath}", appPaths.ProgramDataPath);
|
|
||||||
logger.LogInformation("Web resources path: {WebPath}", appPaths.WebPath);
|
|
||||||
logger.LogInformation("Application directory: {ApplicationPath}", appPaths.ProgramSystemPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
private X509Certificate2 GetCertificate(string path, string password)
|
private X509Certificate2 GetCertificate(string path, string password)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(path))
|
if (string.IsNullOrWhiteSpace(path))
|
||||||
|
@ -782,10 +722,6 @@ namespace Emby.Server.Implementations
|
||||||
|
|
||||||
Resolve<ILiveTvManager>().AddParts(GetExports<ILiveTvService>(), GetExports<ITunerHost>(), GetExports<IListingsProvider>());
|
Resolve<ILiveTvManager>().AddParts(GetExports<ILiveTvService>(), GetExports<ITunerHost>(), GetExports<IListingsProvider>());
|
||||||
|
|
||||||
Resolve<ISubtitleManager>().AddParts(GetExports<ISubtitleProvider>());
|
|
||||||
|
|
||||||
Resolve<IChannelManager>().AddParts(GetExports<IChannel>());
|
|
||||||
|
|
||||||
Resolve<IMediaSourceManager>().AddParts(GetExports<IMediaSourceProvider>());
|
Resolve<IMediaSourceManager>().AddParts(GetExports<IMediaSourceProvider>());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -66,6 +66,7 @@ namespace Emby.Server.Implementations.Channels
|
||||||
/// <param name="userDataManager">The user data manager.</param>
|
/// <param name="userDataManager">The user data manager.</param>
|
||||||
/// <param name="providerManager">The provider manager.</param>
|
/// <param name="providerManager">The provider manager.</param>
|
||||||
/// <param name="memoryCache">The memory cache.</param>
|
/// <param name="memoryCache">The memory cache.</param>
|
||||||
|
/// <param name="channels">The channels.</param>
|
||||||
public ChannelManager(
|
public ChannelManager(
|
||||||
IUserManager userManager,
|
IUserManager userManager,
|
||||||
IDtoService dtoService,
|
IDtoService dtoService,
|
||||||
|
@ -75,7 +76,8 @@ namespace Emby.Server.Implementations.Channels
|
||||||
IFileSystem fileSystem,
|
IFileSystem fileSystem,
|
||||||
IUserDataManager userDataManager,
|
IUserDataManager userDataManager,
|
||||||
IProviderManager providerManager,
|
IProviderManager providerManager,
|
||||||
IMemoryCache memoryCache)
|
IMemoryCache memoryCache,
|
||||||
|
IEnumerable<IChannel> channels)
|
||||||
{
|
{
|
||||||
_userManager = userManager;
|
_userManager = userManager;
|
||||||
_dtoService = dtoService;
|
_dtoService = dtoService;
|
||||||
|
@ -86,18 +88,13 @@ namespace Emby.Server.Implementations.Channels
|
||||||
_userDataManager = userDataManager;
|
_userDataManager = userDataManager;
|
||||||
_providerManager = providerManager;
|
_providerManager = providerManager;
|
||||||
_memoryCache = memoryCache;
|
_memoryCache = memoryCache;
|
||||||
}
|
|
||||||
|
|
||||||
internal IChannel[] Channels { get; private set; }
|
|
||||||
|
|
||||||
private static TimeSpan CacheLength => TimeSpan.FromHours(3);
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public void AddParts(IEnumerable<IChannel> channels)
|
|
||||||
{
|
|
||||||
Channels = channels.ToArray();
|
Channels = channels.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal IChannel[] Channels { get; }
|
||||||
|
|
||||||
|
private static TimeSpan CacheLength => TimeSpan.FromHours(3);
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public bool EnableMediaSourceDisplay(BaseItem item)
|
public bool EnableMediaSourceDisplay(BaseItem item)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
using System.Runtime.Versioning;
|
using System.Runtime.Versioning;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
@ -22,6 +25,43 @@ namespace Jellyfin.Server.Helpers;
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static class StartupHelpers
|
public static class StartupHelpers
|
||||||
{
|
{
|
||||||
|
private static readonly string[] _relevantEnvVarPrefixes = { "JELLYFIN_", "DOTNET_", "ASPNETCORE_" };
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Logs relevant environment variables and information about the host.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="logger">The logger to use.</param>
|
||||||
|
/// <param name="appPaths">The application paths to use.</param>
|
||||||
|
public static void LogEnvironmentInfo(ILogger logger, IApplicationPaths appPaths)
|
||||||
|
{
|
||||||
|
// Distinct these to prevent users from reporting problems that aren't actually problems
|
||||||
|
var commandLineArgs = Environment
|
||||||
|
.GetCommandLineArgs()
|
||||||
|
.Distinct();
|
||||||
|
|
||||||
|
// Get all relevant environment variables
|
||||||
|
var allEnvVars = Environment.GetEnvironmentVariables();
|
||||||
|
var relevantEnvVars = new Dictionary<object, object>();
|
||||||
|
foreach (var key in allEnvVars.Keys)
|
||||||
|
{
|
||||||
|
if (_relevantEnvVarPrefixes.Any(prefix => key.ToString()!.StartsWith(prefix, StringComparison.OrdinalIgnoreCase)))
|
||||||
|
{
|
||||||
|
relevantEnvVars.Add(key, allEnvVars[key]!);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.LogInformation("Environment Variables: {EnvVars}", relevantEnvVars);
|
||||||
|
logger.LogInformation("Arguments: {Args}", commandLineArgs);
|
||||||
|
logger.LogInformation("Operating system: {OS}", RuntimeInformation.OSDescription);
|
||||||
|
logger.LogInformation("Architecture: {Architecture}", RuntimeInformation.OSArchitecture);
|
||||||
|
logger.LogInformation("64-Bit Process: {Is64Bit}", Environment.Is64BitProcess);
|
||||||
|
logger.LogInformation("User Interactive: {IsUserInteractive}", Environment.UserInteractive);
|
||||||
|
logger.LogInformation("Processor count: {ProcessorCount}", Environment.ProcessorCount);
|
||||||
|
logger.LogInformation("Program data path: {ProgramDataPath}", appPaths.ProgramDataPath);
|
||||||
|
logger.LogInformation("Web resources path: {WebPath}", appPaths.WebPath);
|
||||||
|
logger.LogInformation("Application directory: {ApplicationPath}", appPaths.ProgramSystemPath);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create the data, config and log paths from the variety of inputs(command line args,
|
/// Create the data, config and log paths from the variety of inputs(command line args,
|
||||||
/// environment variables) or decide on what default to use. For Windows it's %AppPath%
|
/// environment variables) or decide on what default to use. For Windows it's %AppPath%
|
||||||
|
|
|
@ -148,7 +148,7 @@ namespace Jellyfin.Server
|
||||||
"Jellyfin version: {Version}",
|
"Jellyfin version: {Version}",
|
||||||
Assembly.GetEntryAssembly()!.GetName().Version!.ToString(3));
|
Assembly.GetEntryAssembly()!.GetName().Version!.ToString(3));
|
||||||
|
|
||||||
ApplicationHost.LogEnvironmentInfo(_logger, appPaths);
|
StartupHelpers.LogEnvironmentInfo(_logger, appPaths);
|
||||||
|
|
||||||
// If hosting the web client, validate the client content path
|
// If hosting the web client, validate the client content path
|
||||||
if (startupConfig.HostWebClient())
|
if (startupConfig.HostWebClient())
|
||||||
|
|
|
@ -15,12 +15,6 @@ namespace MediaBrowser.Controller.Channels
|
||||||
{
|
{
|
||||||
public interface IChannelManager
|
public interface IChannelManager
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Adds the parts.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="channels">The channels.</param>
|
|
||||||
void AddParts(IEnumerable<IChannel> channels);
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the channel features.
|
/// Gets the channel features.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -19,12 +19,6 @@ namespace MediaBrowser.Controller.Subtitles
|
||||||
/// </summary>
|
/// </summary>
|
||||||
event EventHandler<SubtitleDownloadFailureEventArgs> SubtitleDownloadFailure;
|
event EventHandler<SubtitleDownloadFailureEventArgs> SubtitleDownloadFailure;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Adds the parts.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="subtitleProviders">The subtitle providers.</param>
|
|
||||||
void AddParts(IEnumerable<ISubtitleProvider> subtitleProviders);
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Searches the subtitles.
|
/// Searches the subtitles.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -35,33 +35,29 @@ namespace MediaBrowser.Providers.Subtitles
|
||||||
private readonly IMediaSourceManager _mediaSourceManager;
|
private readonly IMediaSourceManager _mediaSourceManager;
|
||||||
private readonly ILocalizationManager _localization;
|
private readonly ILocalizationManager _localization;
|
||||||
|
|
||||||
private ISubtitleProvider[] _subtitleProviders;
|
private readonly ISubtitleProvider[] _subtitleProviders;
|
||||||
|
|
||||||
public SubtitleManager(
|
public SubtitleManager(
|
||||||
ILogger<SubtitleManager> logger,
|
ILogger<SubtitleManager> logger,
|
||||||
IFileSystem fileSystem,
|
IFileSystem fileSystem,
|
||||||
ILibraryMonitor monitor,
|
ILibraryMonitor monitor,
|
||||||
IMediaSourceManager mediaSourceManager,
|
IMediaSourceManager mediaSourceManager,
|
||||||
ILocalizationManager localizationManager)
|
ILocalizationManager localizationManager,
|
||||||
|
IEnumerable<ISubtitleProvider> subtitleProviders)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_fileSystem = fileSystem;
|
_fileSystem = fileSystem;
|
||||||
_monitor = monitor;
|
_monitor = monitor;
|
||||||
_mediaSourceManager = mediaSourceManager;
|
_mediaSourceManager = mediaSourceManager;
|
||||||
_localization = localizationManager;
|
_localization = localizationManager;
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public event EventHandler<SubtitleDownloadFailureEventArgs> SubtitleDownloadFailure;
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public void AddParts(IEnumerable<ISubtitleProvider> subtitleProviders)
|
|
||||||
{
|
|
||||||
_subtitleProviders = subtitleProviders
|
_subtitleProviders = subtitleProviders
|
||||||
.OrderBy(i => i is IHasOrder hasOrder ? hasOrder.Order : 0)
|
.OrderBy(i => i is IHasOrder hasOrder ? hasOrder.Order : 0)
|
||||||
.ToArray();
|
.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public event EventHandler<SubtitleDownloadFailureEventArgs> SubtitleDownloadFailure;
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public async Task<RemoteSubtitleInfo[]> SearchSubtitles(SubtitleSearchRequest request, CancellationToken cancellationToken)
|
public async Task<RemoteSubtitleInfo[]> SearchSubtitles(SubtitleSearchRequest request, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue