aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/ApplicationHost.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Emby.Server.Implementations/ApplicationHost.cs')
-rw-r--r--Emby.Server.Implementations/ApplicationHost.cs97
1 files changed, 20 insertions, 77 deletions
diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs
index 07b0807b7..7969577bc 100644
--- a/Emby.Server.Implementations/ApplicationHost.cs
+++ b/Emby.Server.Implementations/ApplicationHost.cs
@@ -11,7 +11,6 @@ using System.IO;
using System.Linq;
using System.Net;
using System.Reflection;
-using System.Runtime.InteropServices;
using System.Security.Cryptography.X509Certificates;
using System.Threading;
using System.Threading.Tasks;
@@ -81,11 +80,13 @@ using MediaBrowser.Controller.Subtitles;
using MediaBrowser.Controller.SyncPlay;
using MediaBrowser.Controller.TV;
using MediaBrowser.LocalMetadata.Savers;
+using MediaBrowser.MediaEncoding.BdInfo;
using MediaBrowser.MediaEncoding.Subtitles;
using MediaBrowser.Model.Cryptography;
using MediaBrowser.Model.Dlna;
using MediaBrowser.Model.Globalization;
using MediaBrowser.Model.IO;
+using MediaBrowser.Model.MediaInfo;
using MediaBrowser.Model.Net;
using MediaBrowser.Model.Serialization;
using MediaBrowser.Model.System;
@@ -114,14 +115,10 @@ namespace Emby.Server.Implementations
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>
/// The disposable parts.
/// </summary>
private readonly ConcurrentDictionary<IDisposable, byte> _disposableParts = new();
+ private readonly DeviceId _deviceId;
private readonly IFileSystem _fileSystemManager;
private readonly IConfiguration _startupConfig;
@@ -130,7 +127,6 @@ namespace Emby.Server.Implementations
private readonly IPluginManager _pluginManager;
private List<Type> _creatingInstances;
- private IMediaEncoder _mediaEncoder;
private ISessionManager _sessionManager;
/// <summary>
@@ -139,8 +135,6 @@ namespace Emby.Server.Implementations
/// <value>All concrete types.</value>
private Type[] _allConcreteTypes;
- private DeviceId _deviceId;
-
private bool _disposed = false;
/// <summary>
@@ -164,6 +158,7 @@ namespace Emby.Server.Implementations
Logger = LoggerFactory.CreateLogger<ApplicationHost>();
_fileSystemManager.AddShortcutHandler(new MbLinkShortcutHandler(_fileSystemManager));
+ _deviceId = new DeviceId(ApplicationPaths, LoggerFactory);
ApplicationVersion = typeof(ApplicationHost).Assembly.GetName().Version;
ApplicationVersionString = ApplicationVersion.ToString(3);
@@ -191,23 +186,9 @@ namespace Emby.Server.Implementations
public bool CoreStartupHasCompleted { get; private set; }
- public virtual bool CanLaunchWebBrowser
- {
- get
- {
- if (!Environment.UserInteractive)
- {
- return false;
- }
-
- if (_startupOptions.IsService)
- {
- return false;
- }
-
- return OperatingSystem.IsWindows() || OperatingSystem.IsMacOS();
- }
- }
+ public virtual bool CanLaunchWebBrowser => Environment.UserInteractive
+ && !_startupOptions.IsService
+ && (OperatingSystem.IsWindows() || OperatingSystem.IsMacOS());
/// <summary>
/// Gets the <see cref="INetworkManager"/> singleton instance.
@@ -284,15 +265,7 @@ namespace Emby.Server.Implementations
/// <value>The application name.</value>
public string ApplicationProductName { get; } = FileVersionInfo.GetVersionInfo(Assembly.GetEntryAssembly().Location).ProductName;
- public string SystemId
- {
- get
- {
- _deviceId ??= new DeviceId(ApplicationPaths, LoggerFactory);
-
- return _deviceId.Value;
- }
- }
+ public string SystemId => _deviceId.Value;
/// <inheritdoc/>
public string Name => ApplicationProductName;
@@ -445,7 +418,7 @@ namespace Emby.Server.Implementations
ConfigurationManager.ConfigurationUpdated += OnConfigurationUpdated;
ConfigurationManager.NamedConfigurationUpdated += OnConfigurationUpdated;
- _mediaEncoder.SetFFmpegPath();
+ Resolve<IMediaEncoder>().SetFFmpegPath();
Logger.LogInformation("ServerId: {ServerId}", SystemId);
@@ -558,6 +531,8 @@ namespace Emby.Server.Implementations
serviceCollection.AddSingleton<ILocalizationManager, LocalizationManager>();
+ serviceCollection.AddSingleton<IBlurayExaminer, BdInfoExaminer>();
+
serviceCollection.AddSingleton<IUserDataRepository, SqliteUserDataRepository>();
serviceCollection.AddSingleton<IUserDataManager, UserDataManager>();
@@ -652,50 +627,19 @@ namespace Emby.Server.Implementations
}
}
+ ((SqliteItemRepository)Resolve<IItemRepository>()).Initialize();
+ ((SqliteUserDataRepository)Resolve<IUserDataRepository>()).Initialize();
+
var localizationManager = (LocalizationManager)Resolve<ILocalizationManager>();
await localizationManager.LoadAll().ConfigureAwait(false);
- _mediaEncoder = Resolve<IMediaEncoder>();
_sessionManager = Resolve<ISessionManager>();
SetStaticProperties();
- var userDataRepo = (SqliteUserDataRepository)Resolve<IUserDataRepository>();
- ((SqliteItemRepository)Resolve<IItemRepository>()).Initialize(userDataRepo, Resolve<IUserManager>());
-
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)
{
if (string.IsNullOrWhiteSpace(path))
@@ -782,10 +726,6 @@ namespace Emby.Server.Implementations
Resolve<ILiveTvManager>().AddParts(GetExports<ILiveTvService>(), GetExports<ITunerHost>(), GetExports<IListingsProvider>());
- Resolve<ISubtitleManager>().AddParts(GetExports<ISubtitleProvider>());
-
- Resolve<IChannelManager>().AddParts(GetExports<IChannel>());
-
Resolve<IMediaSourceManager>().AddParts(GetExports<IMediaSourceProvider>());
}
@@ -1248,10 +1188,13 @@ namespace Emby.Server.Implementations
}
}
- // used for closing websockets
- foreach (var session in _sessionManager.Sessions)
+ if (_sessionManager != null)
{
- await session.DisposeAsync().ConfigureAwait(false);
+ // used for closing websockets
+ foreach (var session in _sessionManager.Sessions)
+ {
+ await session.DisposeAsync().ConfigureAwait(false);
+ }
}
}
}