95220e2ed6
The startup configuration only reads JELLYFIN_ prefixed environment variables, so the bare Jellyfin__TranscodeStore__* form used by the chart, the manifests and the README is dropped and the Redis store is never registered. Nothing logs the selected store, so the fallback is invisible. - Read bare Jellyfin__* variables into the Jellyfin:* configuration root - Keep an explicit JELLYFIN_ variable winning over the bare form - Log the selected transcode session store at startup - Ping Redis once at startup and log an unreachable store at Error - Log endpoints only, never the connection string
52 lines
2.1 KiB
C#
52 lines
2.1 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
namespace Jellyfin.Server.Extensions;
|
|
|
|
/// <summary>
|
|
/// Extensions for building the application configuration.
|
|
/// </summary>
|
|
public static class ConfigurationBuilderExtensions
|
|
{
|
|
/// <summary>
|
|
/// The environment variable prefix that maps onto this fork's own <c>Jellyfin:*</c> configuration
|
|
/// keys, for example <c>Jellyfin__TranscodeStore__RedisConnectionString</c>.
|
|
/// </summary>
|
|
public const string JellyfinSectionEnvironmentPrefix = "Jellyfin__";
|
|
|
|
/// <summary>
|
|
/// The configuration section root this fork keeps its own settings under.
|
|
/// </summary>
|
|
public const string JellyfinSectionRoot = "Jellyfin";
|
|
|
|
/// <summary>
|
|
/// Adds environment variables named <c>Jellyfin__Section__Key</c> as the configuration keys
|
|
/// <c>Jellyfin:Section:Key</c>.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// The base configuration only reads <c>JELLYFIN_</c> prefixed environment variables, so the
|
|
/// unprefixed form every manifest, chart and document uses would otherwise be dropped and the
|
|
/// feature it configures would stay off with no error.
|
|
/// </remarks>
|
|
/// <param name="builder">The configuration builder.</param>
|
|
/// <returns>The updated configuration builder.</returns>
|
|
public static IConfigurationBuilder AddJellyfinSectionEnvironmentVariables(this IConfigurationBuilder builder)
|
|
{
|
|
// Read through the framework provider so "__" to ":" normalisation and case handling match the
|
|
// prefixed form exactly; the prefix it strips is then put back as the section root.
|
|
var scoped = new ConfigurationBuilder()
|
|
.AddEnvironmentVariables(JellyfinSectionEnvironmentPrefix)
|
|
.Build();
|
|
|
|
var entries = scoped.AsEnumerable()
|
|
.Where(entry => entry.Value is not null)
|
|
.Select(entry => new KeyValuePair<string, string?>(
|
|
ConfigurationPath.Combine(JellyfinSectionRoot, entry.Key),
|
|
entry.Value))
|
|
.ToList();
|
|
|
|
return builder.AddInMemoryCollection(entries);
|
|
}
|
|
}
|