mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-09-06 22:07:13 -04:00
Make UNIX socket configurable
This commit is contained in:
parent
9ffe74d979
commit
cbe47325b3
@ -1,6 +1,5 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Emby.Server.Implementations.HttpServer;
|
using Emby.Server.Implementations.HttpServer;
|
||||||
using Emby.Server.Implementations.Updates;
|
|
||||||
using static MediaBrowser.Controller.Extensions.ConfigurationExtensions;
|
using static MediaBrowser.Controller.Extensions.ConfigurationExtensions;
|
||||||
|
|
||||||
namespace Emby.Server.Implementations
|
namespace Emby.Server.Implementations
|
||||||
@ -19,7 +18,8 @@ namespace Emby.Server.Implementations
|
|||||||
{ HttpListenerHost.DefaultRedirectKey, "web/index.html" },
|
{ HttpListenerHost.DefaultRedirectKey, "web/index.html" },
|
||||||
{ FfmpegProbeSizeKey, "1G" },
|
{ FfmpegProbeSizeKey, "1G" },
|
||||||
{ FfmpegAnalyzeDurationKey, "200M" },
|
{ FfmpegAnalyzeDurationKey, "200M" },
|
||||||
{ PlaylistsAllowDuplicatesKey, bool.TrueString }
|
{ PlaylistsAllowDuplicatesKey, bool.TrueString },
|
||||||
|
{ BindToUnixSocketKey, bool.TrueString }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -344,11 +344,24 @@ namespace Jellyfin.Server
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bind to unix socket (only on OSX and Linux)
|
// Bind to unix socket (only on macOS and Linux)
|
||||||
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
if (startupConfig.UseUnixSocket() && !RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||||
{
|
{
|
||||||
// TODO: allow configuration of socket path
|
var socketPath = startupConfig.GetUnixSocketPath();
|
||||||
var socketPath = $"{appPaths.DataPath}/socket.sock";
|
if (string.IsNullOrEmpty(socketPath))
|
||||||
|
{
|
||||||
|
var xdgRuntimeDir = Environment.GetEnvironmentVariable("XDG_RUNTIME_DIR");
|
||||||
|
if (xdgRuntimeDir == null)
|
||||||
|
{
|
||||||
|
// Fall back to config dir
|
||||||
|
socketPath = Path.Join(appPaths.ConfigurationDirectoryPath, "socket.sock");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
socketPath = Path.Join(xdgRuntimeDir, "jellyfin-socket");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Workaround for https://github.com/aspnet/AspNetCore/issues/14134
|
// Workaround for https://github.com/aspnet/AspNetCore/issues/14134
|
||||||
if (File.Exists(socketPath))
|
if (File.Exists(socketPath))
|
||||||
{
|
{
|
||||||
|
@ -33,6 +33,16 @@ namespace MediaBrowser.Controller.Extensions
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public const string PlaylistsAllowDuplicatesKey = "playlists:allowDuplicates";
|
public const string PlaylistsAllowDuplicatesKey = "playlists:allowDuplicates";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The key for a setting that indicates whether kestrel should bind to a unix socket.
|
||||||
|
/// </summary>
|
||||||
|
public const string BindToUnixSocketKey = "kerstrel:socket";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The key for the unix socket path.
|
||||||
|
/// </summary>
|
||||||
|
public const string UnixSocketPathKey = "kerstrel:socketPath";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a value indicating whether the application should host static web content from the <see cref="IConfiguration"/>.
|
/// Gets a value indicating whether the application should host static web content from the <see cref="IConfiguration"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -65,5 +75,21 @@ namespace MediaBrowser.Controller.Extensions
|
|||||||
/// <returns>True if playlists should allow duplicates, otherwise false.</returns>
|
/// <returns>True if playlists should allow duplicates, otherwise false.</returns>
|
||||||
public static bool DoPlaylistsAllowDuplicates(this IConfiguration configuration)
|
public static bool DoPlaylistsAllowDuplicates(this IConfiguration configuration)
|
||||||
=> configuration.GetValue<bool>(PlaylistsAllowDuplicatesKey);
|
=> configuration.GetValue<bool>(PlaylistsAllowDuplicatesKey);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a value indicating whether kestrel should bind to a unix socket from the <see cref="IConfiguration" />.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="configuration">The configuration to read the setting from.</param>
|
||||||
|
/// <returns><c>true</c> if kestrel should bind to a unix socket, otherwise <c>false</c>.</returns>
|
||||||
|
public static bool UseUnixSocket(this IConfiguration configuration)
|
||||||
|
=> configuration.GetValue<bool>(BindToUnixSocketKey);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the path for the unix socket from the <see cref="IConfiguration" />.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="configuration">The configuration to read the setting from.</param>
|
||||||
|
/// <returns>The unix socket path.</returns>
|
||||||
|
public static string GetUnixSocketPath(this IConfiguration configuration)
|
||||||
|
=> configuration[FfmpegAnalyzeDurationKey];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user