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.cs85
1 files changed, 21 insertions, 64 deletions
diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs
index c959cc974..81a80ddb2 100644
--- a/Emby.Server.Implementations/ApplicationHost.cs
+++ b/Emby.Server.Implementations/ApplicationHost.cs
@@ -30,7 +30,6 @@ using Emby.Server.Implementations.Configuration;
using Emby.Server.Implementations.Cryptography;
using Emby.Server.Implementations.Data;
using Emby.Server.Implementations.Devices;
-using Emby.Server.Implementations.Diagnostics;
using Emby.Server.Implementations.Dto;
using Emby.Server.Implementations.HttpServer;
using Emby.Server.Implementations.HttpServer.Security;
@@ -86,7 +85,6 @@ using MediaBrowser.MediaEncoding.BdInfo;
using MediaBrowser.Model.Activity;
using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.Cryptography;
-using MediaBrowser.Model.Diagnostics;
using MediaBrowser.Model.Dlna;
using MediaBrowser.Model.Events;
using MediaBrowser.Model.Globalization;
@@ -118,6 +116,11 @@ namespace Emby.Server.Implementations
/// </summary>
public abstract class ApplicationHost : IServerApplicationHost, IDisposable
{
+ /// <summary>
+ /// The environment variable prefixes to log at server startup.
+ /// </summary>
+ private static readonly string[] _relevantEnvVarPrefixes = { "JELLYFIN_", "DOTNET_", "ASPNETCORE_" };
+
private SqliteUserRepository _userRepository;
private SqliteDisplayPreferencesRepository _displayPreferencesRepository;
@@ -332,8 +335,6 @@ namespace Emby.Server.Implementations
internal IImageEncoder ImageEncoder { get; private set; }
- protected IProcessFactory ProcessFactory { get; private set; }
-
protected readonly IXmlSerializer XmlSerializer;
protected ISocketFactory SocketFactory { get; private set; }
@@ -675,9 +676,6 @@ namespace Emby.Server.Implementations
serviceCollection.AddSingleton(XmlSerializer);
- ProcessFactory = new ProcessFactory();
- serviceCollection.AddSingleton(ProcessFactory);
-
serviceCollection.AddSingleton(typeof(IStreamHelper), typeof(StreamHelper));
var cryptoProvider = new CryptographyProvider();
@@ -738,7 +736,6 @@ namespace Emby.Server.Implementations
LoggerFactory.CreateLogger<MediaBrowser.MediaEncoding.Encoder.MediaEncoder>(),
ServerConfigurationManager,
FileSystemManager,
- ProcessFactory,
LocalizationManager,
() => SubtitleEncoder,
startupConfig,
@@ -852,8 +849,7 @@ namespace Emby.Server.Implementations
FileSystemManager,
MediaEncoder,
HttpClient,
- MediaSourceManager,
- ProcessFactory);
+ MediaSourceManager);
serviceCollection.AddSingleton(SubtitleEncoder);
serviceCollection.AddSingleton(typeof(IResourceFileManager), typeof(ResourceFileManager));
@@ -889,18 +885,18 @@ namespace Emby.Server.Implementations
.GetCommandLineArgs()
.Distinct();
- // Get all 'JELLYFIN_' prefixed environment variables
+ // Get all relevant environment variables
var allEnvVars = Environment.GetEnvironmentVariables();
- var jellyfinEnvVars = new Dictionary<object, object>();
+ var relevantEnvVars = new Dictionary<object, object>();
foreach (var key in allEnvVars.Keys)
{
- if (key.ToString().StartsWith("JELLYFIN_", StringComparison.OrdinalIgnoreCase))
+ if (_relevantEnvVarPrefixes.Any(prefix => key.ToString().StartsWith(prefix, StringComparison.OrdinalIgnoreCase)))
{
- jellyfinEnvVars.Add(key, allEnvVars[key]);
+ relevantEnvVars.Add(key, allEnvVars[key]);
}
}
- logger.LogInformation("Environment Variables: {EnvVars}", jellyfinEnvVars);
+ logger.LogInformation("Environment Variables: {EnvVars}", relevantEnvVars);
logger.LogInformation("Arguments: {Args}", commandLineArgs);
logger.LogInformation("Operating system: {OS}", OperatingSystem.Name);
logger.LogInformation("Architecture: {Architecture}", RuntimeInformation.OSArchitecture);
@@ -1010,48 +1006,12 @@ namespace Emby.Server.Implementations
AuthenticatedAttribute.AuthService = AuthService;
}
- private async void PluginInstalled(object sender, GenericEventArgs<PackageVersionInfo> args)
- {
- string dir = Path.Combine(ApplicationPaths.PluginsPath, args.Argument.name);
- var types = Directory.EnumerateFiles(dir, "*.dll", SearchOption.AllDirectories)
- .Select(Assembly.LoadFrom)
- .SelectMany(x => x.ExportedTypes)
- .Where(x => x.IsClass && !x.IsAbstract && !x.IsInterface && !x.IsGenericType)
- .ToArray();
-
- int oldLen = _allConcreteTypes.Length;
- Array.Resize(ref _allConcreteTypes, oldLen + types.Length);
- types.CopyTo(_allConcreteTypes, oldLen);
-
- var plugins = types.Where(x => x.IsAssignableFrom(typeof(IPlugin)))
- .Select(CreateInstanceSafe)
- .Where(x => x != null)
- .Cast<IPlugin>()
- .Select(LoadPlugin)
- .Where(x => x != null)
- .ToArray();
-
- oldLen = _plugins.Length;
- Array.Resize(ref _plugins, oldLen + plugins.Length);
- plugins.CopyTo(_plugins, oldLen);
-
- var entries = types.Where(x => x.IsAssignableFrom(typeof(IServerEntryPoint)))
- .Select(CreateInstanceSafe)
- .Where(x => x != null)
- .Cast<IServerEntryPoint>()
- .ToList();
-
- await Task.WhenAll(StartEntryPoints(entries, true)).ConfigureAwait(false);
- await Task.WhenAll(StartEntryPoints(entries, false)).ConfigureAwait(false);
- }
-
/// <summary>
/// Finds the parts.
/// </summary>
public void FindParts()
{
InstallationManager = ServiceProvider.GetService<IInstallationManager>();
- InstallationManager.PluginInstalled += PluginInstalled;
if (!ServerConfigurationManager.Configuration.IsPortAuthorized)
{
@@ -1709,15 +1669,17 @@ namespace Emby.Server.Implementations
throw new NotSupportedException();
}
- var process = ProcessFactory.Create(new ProcessOptions
+ var process = new Process
{
- FileName = url,
- EnableRaisingEvents = true,
- UseShellExecute = true,
- ErrorDialog = false
- });
-
- process.Exited += ProcessExited;
+ StartInfo = new ProcessStartInfo
+ {
+ FileName = url,
+ UseShellExecute = true,
+ ErrorDialog = false
+ },
+ EnableRaisingEvents = true
+ };
+ process.Exited += (sender, args) => ((Process)sender).Dispose();
try
{
@@ -1730,11 +1692,6 @@ namespace Emby.Server.Implementations
}
}
- private static void ProcessExited(object sender, EventArgs e)
- {
- ((IProcess)sender).Dispose();
- }
-
public virtual void EnableLoopback(string appName)
{
}