aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBond_009 <Bond.009@outlook.com>2020-07-23 13:18:47 +0200
committerBond_009 <Bond.009@outlook.com>2020-07-23 13:18:47 +0200
commitcbe47325b328b70e5a49dc231a70d3709f71dbbd (patch)
treef07fd1e11340d377b4d9f0cd6a5dec6becca6e9e
parent9ffe74d97914c82c88f1664a991d2cb65f14a827 (diff)
Make UNIX socket configurable
-rw-r--r--Emby.Server.Implementations/ConfigurationOptions.cs4
-rw-r--r--Jellyfin.Server/Program.cs21
-rw-r--r--MediaBrowser.Controller/Extensions/ConfigurationExtensions.cs26
3 files changed, 45 insertions, 6 deletions
diff --git a/Emby.Server.Implementations/ConfigurationOptions.cs b/Emby.Server.Implementations/ConfigurationOptions.cs
index ff7ee085f..9a4693db0 100644
--- a/Emby.Server.Implementations/ConfigurationOptions.cs
+++ b/Emby.Server.Implementations/ConfigurationOptions.cs
@@ -1,6 +1,5 @@
using System.Collections.Generic;
using Emby.Server.Implementations.HttpServer;
-using Emby.Server.Implementations.Updates;
using static MediaBrowser.Controller.Extensions.ConfigurationExtensions;
namespace Emby.Server.Implementations
@@ -19,7 +18,8 @@ namespace Emby.Server.Implementations
{ HttpListenerHost.DefaultRedirectKey, "web/index.html" },
{ FfmpegProbeSizeKey, "1G" },
{ FfmpegAnalyzeDurationKey, "200M" },
- { PlaylistsAllowDuplicatesKey, bool.TrueString }
+ { PlaylistsAllowDuplicatesKey, bool.TrueString },
+ { BindToUnixSocketKey, bool.TrueString }
};
}
}
diff --git a/Jellyfin.Server/Program.cs b/Jellyfin.Server/Program.cs
index 444a91c02..f3ee339d1 100644
--- a/Jellyfin.Server/Program.cs
+++ b/Jellyfin.Server/Program.cs
@@ -344,11 +344,24 @@ namespace Jellyfin.Server
}
}
- // Bind to unix socket (only on OSX and Linux)
- if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
+ // Bind to unix socket (only on macOS and Linux)
+ if (startupConfig.UseUnixSocket() && !RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
- // TODO: allow configuration of socket path
- var socketPath = $"{appPaths.DataPath}/socket.sock";
+ var socketPath = startupConfig.GetUnixSocketPath();
+ 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
if (File.Exists(socketPath))
{
diff --git a/MediaBrowser.Controller/Extensions/ConfigurationExtensions.cs b/MediaBrowser.Controller/Extensions/ConfigurationExtensions.cs
index c2932cc4c..ae02c1cee 100644
--- a/MediaBrowser.Controller/Extensions/ConfigurationExtensions.cs
+++ b/MediaBrowser.Controller/Extensions/ConfigurationExtensions.cs
@@ -34,6 +34,16 @@ namespace MediaBrowser.Controller.Extensions
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>
/// Gets a value indicating whether the application should host static web content from the <see cref="IConfiguration"/>.
/// </summary>
/// <param name="configuration">The configuration to retrieve the value from.</param>
@@ -65,5 +75,21 @@ namespace MediaBrowser.Controller.Extensions
/// <returns>True if playlists should allow duplicates, otherwise false.</returns>
public static bool DoPlaylistsAllowDuplicates(this IConfiguration configuration)
=> 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];
}
}