aboutsummaryrefslogtreecommitdiff
path: root/Jellyfin.Server
diff options
context:
space:
mode:
authorClaus Vium <cvium@users.noreply.github.com>2021-11-03 13:01:37 +0100
committerGitHub <noreply@github.com>2021-11-03 13:01:37 +0100
commit01875003734116088d8a800faa2500684a3dbe92 (patch)
tree168efc2401b8e4aa0552a02441527164e286b2a8 /Jellyfin.Server
parent869d537aaa4666db1e1ab6f28123d0a825af3e03 (diff)
parent104e36f2f9c6440a7547a4c76d80a69d5af84eea (diff)
Merge pull request #6761 from Bond-009/startup2
Diffstat (limited to 'Jellyfin.Server')
-rw-r--r--Jellyfin.Server/CoreAppHost.cs49
-rw-r--r--Jellyfin.Server/Program.cs41
2 files changed, 42 insertions, 48 deletions
diff --git a/Jellyfin.Server/CoreAppHost.cs b/Jellyfin.Server/CoreAppHost.cs
index 21bd9ba011..67e50b92d9 100644
--- a/Jellyfin.Server/CoreAppHost.cs
+++ b/Jellyfin.Server/CoreAppHost.cs
@@ -22,7 +22,6 @@ using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Net;
using MediaBrowser.Controller.Security;
using MediaBrowser.Model.Activity;
-using MediaBrowser.Model.IO;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
@@ -42,67 +41,61 @@ namespace Jellyfin.Server
/// <param name="loggerFactory">The <see cref="ILoggerFactory" /> to be used by the <see cref="CoreAppHost" />.</param>
/// <param name="options">The <see cref="StartupOptions" /> to be used by the <see cref="CoreAppHost" />.</param>
/// <param name="startupConfig">The <see cref="IConfiguration" /> to be used by the <see cref="CoreAppHost" />.</param>
- /// <param name="fileSystem">The <see cref="IFileSystem" /> to be used by the <see cref="CoreAppHost" />.</param>
- /// <param name="collection">The <see cref="IServiceCollection"/> to be used by the <see cref="CoreAppHost"/>.</param>
public CoreAppHost(
IServerApplicationPaths applicationPaths,
ILoggerFactory loggerFactory,
IStartupOptions options,
- IConfiguration startupConfig,
- IFileSystem fileSystem,
- IServiceCollection collection)
+ IConfiguration startupConfig)
: base(
applicationPaths,
loggerFactory,
options,
- startupConfig,
- fileSystem,
- collection)
+ startupConfig)
{
}
/// <inheritdoc/>
- protected override void RegisterServices()
+ protected override void RegisterServices(IServiceCollection serviceCollection)
{
// Register an image encoder
bool useSkiaEncoder = SkiaEncoder.IsNativeLibAvailable();
Type imageEncoderType = useSkiaEncoder
? typeof(SkiaEncoder)
: typeof(NullImageEncoder);
- ServiceCollection.AddSingleton(typeof(IImageEncoder), imageEncoderType);
+ serviceCollection.AddSingleton(typeof(IImageEncoder), imageEncoderType);
// Log a warning if the Skia encoder could not be used
if (!useSkiaEncoder)
{
- Logger.LogWarning($"Skia not available. Will fallback to {nameof(NullImageEncoder)}.");
+ Logger.LogWarning("Skia not available. Will fallback to {ImageEncoder}.", nameof(NullImageEncoder));
}
- ServiceCollection.AddDbContextPool<JellyfinDb>(
+ serviceCollection.AddDbContextPool<JellyfinDb>(
options => options
.UseLoggerFactory(LoggerFactory)
.UseSqlite($"Filename={Path.Combine(ApplicationPaths.DataPath, "jellyfin.db")}"));
- ServiceCollection.AddEventServices();
- ServiceCollection.AddSingleton<IBaseItemManager, BaseItemManager>();
- ServiceCollection.AddSingleton<IEventManager, EventManager>();
- ServiceCollection.AddSingleton<JellyfinDbProvider>();
+ serviceCollection.AddEventServices();
+ serviceCollection.AddSingleton<IBaseItemManager, BaseItemManager>();
+ serviceCollection.AddSingleton<IEventManager, EventManager>();
+ serviceCollection.AddSingleton<JellyfinDbProvider>();
- ServiceCollection.AddSingleton<IActivityManager, ActivityManager>();
- ServiceCollection.AddSingleton<IUserManager, UserManager>();
- ServiceCollection.AddSingleton<IDisplayPreferencesManager, DisplayPreferencesManager>();
- ServiceCollection.AddSingleton<IDeviceManager, DeviceManager>();
+ serviceCollection.AddSingleton<IActivityManager, ActivityManager>();
+ serviceCollection.AddSingleton<IUserManager, UserManager>();
+ serviceCollection.AddSingleton<IDisplayPreferencesManager, DisplayPreferencesManager>();
+ serviceCollection.AddSingleton<IDeviceManager, DeviceManager>();
// TODO search the assemblies instead of adding them manually?
- ServiceCollection.AddSingleton<IWebSocketListener, SessionWebSocketListener>();
- ServiceCollection.AddSingleton<IWebSocketListener, ActivityLogWebSocketListener>();
- ServiceCollection.AddSingleton<IWebSocketListener, ScheduledTasksWebSocketListener>();
- ServiceCollection.AddSingleton<IWebSocketListener, SessionInfoWebSocketListener>();
+ serviceCollection.AddSingleton<IWebSocketListener, SessionWebSocketListener>();
+ serviceCollection.AddSingleton<IWebSocketListener, ActivityLogWebSocketListener>();
+ serviceCollection.AddSingleton<IWebSocketListener, ScheduledTasksWebSocketListener>();
+ serviceCollection.AddSingleton<IWebSocketListener, SessionInfoWebSocketListener>();
- ServiceCollection.AddSingleton<IAuthorizationContext, AuthorizationContext>();
+ serviceCollection.AddSingleton<IAuthorizationContext, AuthorizationContext>();
- ServiceCollection.AddScoped<IAuthenticationManager, AuthenticationManager>();
+ serviceCollection.AddScoped<IAuthenticationManager, AuthenticationManager>();
- base.RegisterServices();
+ base.RegisterServices(serviceCollection);
}
/// <inheritdoc />
diff --git a/Jellyfin.Server/Program.cs b/Jellyfin.Server/Program.cs
index 45699f3aff..5f848be9e1 100644
--- a/Jellyfin.Server/Program.cs
+++ b/Jellyfin.Server/Program.cs
@@ -10,7 +10,6 @@ using System.Threading;
using System.Threading.Tasks;
using CommandLine;
using Emby.Server.Implementations;
-using Emby.Server.Implementations.IO;
using Jellyfin.Server.Implementations;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Common.Net;
@@ -157,34 +156,36 @@ namespace Jellyfin.Server
ApplicationHost.LogEnvironmentInfo(_logger, appPaths);
+ // If hosting the web client, validate the client content path
+ if (startupConfig.HostWebClient())
+ {
+ string? webContentPath = appPaths.WebPath;
+ if (!Directory.Exists(webContentPath) || !Directory.EnumerateFiles(webContentPath).Any())
+ {
+ _logger.LogError(
+ "The server is expected to host the web client, but the provided content directory is either " +
+ "invalid or empty: {WebContentPath}. If you do not want to host the web client with the " +
+ "server, you may set the '--nowebclient' command line flag, or set" +
+ "'{ConfigKey}=false' in your config settings.",
+ webContentPath,
+ ConfigurationExtensions.HostWebClientKey);
+ Environment.ExitCode = 1;
+ return;
+ }
+ }
+
PerformStaticInitialization();
- var serviceCollection = new ServiceCollection();
var appHost = new CoreAppHost(
appPaths,
_loggerFactory,
options,
- startupConfig,
- new ManagedFileSystem(_loggerFactory.CreateLogger<ManagedFileSystem>(), appPaths),
- serviceCollection);
+ startupConfig);
try
{
- // If hosting the web client, validate the client content path
- if (startupConfig.HostWebClient())
- {
- string? webContentPath = appHost.ConfigurationManager.ApplicationPaths.WebPath;
- if (!Directory.Exists(webContentPath) || Directory.GetFiles(webContentPath).Length == 0)
- {
- throw new InvalidOperationException(
- "The server is expected to host the web client, but the provided content directory is either " +
- $"invalid or empty: {webContentPath}. If you do not want to host the web client with the " +
- "server, you may set the '--nowebclient' command line flag, or set" +
- $"'{ConfigurationExtensions.HostWebClientKey}=false' in your config settings.");
- }
- }
-
- appHost.Init();
+ var serviceCollection = new ServiceCollection();
+ appHost.Init(serviceCollection);
var webHost = new WebHostBuilder().ConfigureWebHostBuilder(appHost, serviceCollection, options, startupConfig, appPaths).Build();