Add file-based startup config & temp dir option

Added support for configuring all major Jellyfin paths (data, config, cache, log, temp, web) via a `startup.json` file, with priority after CLI and environment variables. Introduced a new `TempDir` option, configurable through CLI, env var, or config file, with backward-compatible defaults. Refactored path resolution logic to integrate file-based config and ensure directory creation. Updated constructors and CLI options to support temp directory. Improved EF Core migration error handling and logging. Added comprehensive documentation and example config files. All changes are backward compatible.
This commit is contained in:
2026-02-25 15:18:23 -05:00
parent dad5cbadf5
commit c38adfc0f7
15 changed files with 1764 additions and 22 deletions
@@ -157,7 +157,9 @@ public sealed class PostgresDatabaseProvider : IJellyfinDatabaseProvider
options
.UseNpgsql(
connectionString,
npgsqlOptions => npgsqlOptions.MigrationsAssembly(GetType().Assembly.FullName));
npgsqlOptions => npgsqlOptions.MigrationsAssembly(GetType().Assembly.FullName))
.ConfigureWarnings(warnings =>
warnings.Ignore(Microsoft.EntityFrameworkCore.Diagnostics.RelationalEventId.PendingModelChangesWarning));
var enableSensitiveDataLogging = GetOption(customOptions, "EnableSensitiveDataLogging", e => e.Equals(bool.TrueString, StringComparison.OrdinalIgnoreCase), () => false);
if (enableSensitiveDataLogging)
@@ -341,12 +343,22 @@ public sealed class PostgresDatabaseProvider : IJellyfinDatabaseProvider
if (pendingMigrationsList.Count > 0)
{
logger.LogInformation("Found {Count} pending migrations. Applying migrations...", pendingMigrationsList.Count);
logger.LogInformation("Found {Count} pending migrations: {Migrations}", pendingMigrationsList.Count, string.Join(", ", pendingMigrationsList));
logger.LogInformation("Applying migrations...");
// Apply all pending migrations
await context.Database.MigrateAsync(cancellationToken).ConfigureAwait(false);
logger.LogInformation("Successfully applied {Count} migrations", pendingMigrationsList.Count);
try
{
// Apply all pending migrations
await context.Database.MigrateAsync(cancellationToken).ConfigureAwait(false);
logger.LogInformation("Successfully applied {Count} migrations", pendingMigrationsList.Count);
}
catch (InvalidOperationException ex) when (ex.Message.Contains("pending changes", StringComparison.OrdinalIgnoreCase))
{
// This can happen if the model has changed but migrations haven't been generated
logger.LogWarning("Model has pending changes. This may indicate missing migration files. Error: {Message}", ex.Message);
logger.LogWarning("If you're seeing this on a test/production system, ensure all migration files are deployed.");
throw;
}
}
else
{