Move Options to Jellyfin.Server and create interface file
Changes following review comments.
This commit is contained in:
parent
ebd2a30087
commit
e18b89ca27
|
@ -43,6 +43,7 @@ using Emby.Server.Implementations.ScheduledTasks;
|
||||||
using Emby.Server.Implementations.Security;
|
using Emby.Server.Implementations.Security;
|
||||||
using Emby.Server.Implementations.Serialization;
|
using Emby.Server.Implementations.Serialization;
|
||||||
using Emby.Server.Implementations.Session;
|
using Emby.Server.Implementations.Session;
|
||||||
|
using Emby.Server.Implementations.ParsedStartupOptions;
|
||||||
using Emby.Server.Implementations.Threading;
|
using Emby.Server.Implementations.Threading;
|
||||||
using Emby.Server.Implementations.TV;
|
using Emby.Server.Implementations.TV;
|
||||||
using Emby.Server.Implementations.Updates;
|
using Emby.Server.Implementations.Updates;
|
||||||
|
@ -141,7 +142,7 @@ namespace Emby.Server.Implementations
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (StartupOptions.Service)
|
if (StartupOptions.IsService)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -343,7 +344,7 @@ namespace Emby.Server.Implementations
|
||||||
protected IHttpResultFactory HttpResultFactory { get; private set; }
|
protected IHttpResultFactory HttpResultFactory { get; private set; }
|
||||||
protected IAuthService AuthService { get; private set; }
|
protected IAuthService AuthService { get; private set; }
|
||||||
|
|
||||||
public StartupOptions StartupOptions { get; private set; }
|
public IStartupOptions StartupOptions { get; private set; }
|
||||||
|
|
||||||
internal IImageEncoder ImageEncoder { get; private set; }
|
internal IImageEncoder ImageEncoder { get; private set; }
|
||||||
|
|
||||||
|
@ -364,7 +365,7 @@ namespace Emby.Server.Implementations
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ApplicationHost(ServerApplicationPaths applicationPaths,
|
public ApplicationHost(ServerApplicationPaths applicationPaths,
|
||||||
ILoggerFactory loggerFactory,
|
ILoggerFactory loggerFactory,
|
||||||
StartupOptions options,
|
IStartupOptions options,
|
||||||
IFileSystem fileSystem,
|
IFileSystem fileSystem,
|
||||||
IEnvironmentInfo environmentInfo,
|
IEnvironmentInfo environmentInfo,
|
||||||
IImageEncoder imageEncoder,
|
IImageEncoder imageEncoder,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Emby.Naming\Emby.Naming.csproj" />
|
<ProjectReference Include="..\Emby.Naming\Emby.Naming.csproj" />
|
||||||
|
@ -22,7 +22,6 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="CommandLineParser" Version="2.4.3" />
|
|
||||||
<PackageReference Include="ServiceStack.Text.Core" Version="5.4.0" />
|
<PackageReference Include="ServiceStack.Text.Core" Version="5.4.0" />
|
||||||
<PackageReference Include="sharpcompress" Version="0.22.0" />
|
<PackageReference Include="sharpcompress" Version="0.22.0" />
|
||||||
<PackageReference Include="SimpleInjector" Version="4.4.2" />
|
<PackageReference Include="SimpleInjector" Version="4.4.2" />
|
||||||
|
|
|
@ -47,7 +47,7 @@ namespace Emby.Server.Implementations.EntryPoints
|
||||||
{
|
{
|
||||||
var options = ((ApplicationHost)_appHost).StartupOptions;
|
var options = ((ApplicationHost)_appHost).StartupOptions;
|
||||||
|
|
||||||
if (!options.NoAutoRunWebApp)
|
if (options.AutoRunWebApp)
|
||||||
{
|
{
|
||||||
BrowserLauncher.OpenWebApp(_appHost);
|
BrowserLauncher.OpenWebApp(_appHost);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ using MediaBrowser.Common.Configuration;
|
||||||
using MediaBrowser.Common.Net;
|
using MediaBrowser.Common.Net;
|
||||||
using MediaBrowser.Model.IO;
|
using MediaBrowser.Model.IO;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Emby.Server.Implementations.ParsedStartupOptions;
|
||||||
|
|
||||||
namespace Emby.Server.Implementations.FFMpeg
|
namespace Emby.Server.Implementations.FFMpeg
|
||||||
{
|
{
|
||||||
|
@ -28,10 +29,10 @@ namespace Emby.Server.Implementations.FFMpeg
|
||||||
_ffmpegInstallInfo = ffmpegInstallInfo;
|
_ffmpegInstallInfo = ffmpegInstallInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FFMpegInfo GetFFMpegInfo(StartupOptions options)
|
public FFMpegInfo GetFFMpegInfo(IStartupOptions options)
|
||||||
{
|
{
|
||||||
var customffMpegPath = options.FFmpeg;
|
var customffMpegPath = options.FFmpegPath;
|
||||||
var customffProbePath = options.FFprobe;
|
var customffProbePath = options.FFprobePath;
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(customffMpegPath) && !string.IsNullOrWhiteSpace(customffProbePath))
|
if (!string.IsNullOrWhiteSpace(customffMpegPath) && !string.IsNullOrWhiteSpace(customffProbePath))
|
||||||
{
|
{
|
||||||
|
|
55
Emby.Server.Implementations/IStartupOptions.cs
Normal file
55
Emby.Server.Implementations/IStartupOptions.cs
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
namespace Emby.Server.Implementations.ParsedStartupOptions
|
||||||
|
{
|
||||||
|
public interface IStartupOptions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// --datadir
|
||||||
|
/// </summary>
|
||||||
|
string DataDir { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// --configdir
|
||||||
|
/// </summary>
|
||||||
|
string ConfigDir { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// --logdir
|
||||||
|
/// </summary>
|
||||||
|
string LogDir { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// --ffmpeg
|
||||||
|
/// </summary>
|
||||||
|
string FFmpegPath { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// --ffprobe
|
||||||
|
/// </summary>
|
||||||
|
string FFprobePath { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// --service
|
||||||
|
/// </summary>
|
||||||
|
bool IsService { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// --noautorunwebapp
|
||||||
|
/// </summary>
|
||||||
|
bool AutoRunWebApp { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// --package-name
|
||||||
|
/// </summary>
|
||||||
|
string PackageName { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// --restartpath
|
||||||
|
/// </summary>
|
||||||
|
string RestartPath { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// --restartargs
|
||||||
|
/// </summary>
|
||||||
|
string RestartArgs { get; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -32,6 +32,7 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="CommandLineParser" Version="2.4.3" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="2.2.0" />
|
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="2.2.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.2.0" />
|
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.2.0" />
|
||||||
<PackageReference Include="Serilog.AspNetCore" Version="2.1.1" />
|
<PackageReference Include="Serilog.AspNetCore" Version="2.1.1" />
|
||||||
|
|
|
@ -6,8 +6,10 @@ using System.Net;
|
||||||
using System.Net.Security;
|
using System.Net.Security;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using CommandLine;
|
||||||
using Emby.Drawing;
|
using Emby.Drawing;
|
||||||
using Emby.Server.Implementations;
|
using Emby.Server.Implementations;
|
||||||
using Emby.Server.Implementations.EnvironmentInfo;
|
using Emby.Server.Implementations.EnvironmentInfo;
|
||||||
|
@ -26,9 +28,6 @@ using ILogger = Microsoft.Extensions.Logging.ILogger;
|
||||||
|
|
||||||
namespace Jellyfin.Server
|
namespace Jellyfin.Server
|
||||||
{
|
{
|
||||||
using CommandLine;
|
|
||||||
using System.Text.RegularExpressions;
|
|
||||||
|
|
||||||
public static class Program
|
public static class Program
|
||||||
{
|
{
|
||||||
private static readonly CancellationTokenSource _tokenSource = new CancellationTokenSource();
|
private static readonly CancellationTokenSource _tokenSource = new CancellationTokenSource();
|
||||||
|
@ -41,8 +40,8 @@ namespace Jellyfin.Server
|
||||||
// For backwards compatibility.
|
// For backwards compatibility.
|
||||||
// Modify any input arguments now which start with single-hyphen to POSIX standard
|
// Modify any input arguments now which start with single-hyphen to POSIX standard
|
||||||
// double-hyphen to allow parsing by CommandLineParser package.
|
// double-hyphen to allow parsing by CommandLineParser package.
|
||||||
var pattern = @"^(-[^-\s]{2})"; // Match -xx, not -x, not --xx, not xx
|
const string pattern = @"^(-[^-\s]{2})"; // Match -xx, not -x, not --xx, not xx
|
||||||
var substitution = @"-$1"; // Prepend with additional single-hyphen
|
const string substitution = @"-$1"; // Prepend with additional single-hyphen
|
||||||
var regex = new Regex(pattern);
|
var regex = new Regex(pattern);
|
||||||
|
|
||||||
for (var i = 0; i < args.Length; i++)
|
for (var i = 0; i < args.Length; i++)
|
||||||
|
@ -152,9 +151,9 @@ namespace Jellyfin.Server
|
||||||
string programDataPath = Environment.GetEnvironmentVariable("JELLYFIN_DATA_PATH");
|
string programDataPath = Environment.GetEnvironmentVariable("JELLYFIN_DATA_PATH");
|
||||||
if (string.IsNullOrEmpty(programDataPath))
|
if (string.IsNullOrEmpty(programDataPath))
|
||||||
{
|
{
|
||||||
if (options.PathData != null)
|
if (options.DataDir != null)
|
||||||
{
|
{
|
||||||
programDataPath = options.PathData;
|
programDataPath = options.DataDir;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -190,9 +189,9 @@ namespace Jellyfin.Server
|
||||||
string configDir = Environment.GetEnvironmentVariable("JELLYFIN_CONFIG_DIR");
|
string configDir = Environment.GetEnvironmentVariable("JELLYFIN_CONFIG_DIR");
|
||||||
if (string.IsNullOrEmpty(configDir))
|
if (string.IsNullOrEmpty(configDir))
|
||||||
{
|
{
|
||||||
if (options.PathConfig != null)
|
if (options.ConfigDir != null)
|
||||||
{
|
{
|
||||||
configDir = options.PathConfig;
|
configDir = options.ConfigDir;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -209,9 +208,9 @@ namespace Jellyfin.Server
|
||||||
string logDir = Environment.GetEnvironmentVariable("JELLYFIN_LOG_DIR");
|
string logDir = Environment.GetEnvironmentVariable("JELLYFIN_LOG_DIR");
|
||||||
if (string.IsNullOrEmpty(logDir))
|
if (string.IsNullOrEmpty(logDir))
|
||||||
{
|
{
|
||||||
if (options.PathLog != null)
|
if (options.LogDir != null)
|
||||||
{
|
{
|
||||||
logDir = options.PathLog;
|
logDir = options.LogDir;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,43 +1,47 @@
|
||||||
namespace Emby.Server.Implementations
|
using CommandLine;
|
||||||
{
|
using Emby.Server.Implementations.ParsedStartupOptions;
|
||||||
using CommandLine;
|
|
||||||
|
|
||||||
|
namespace Jellyfin.Server
|
||||||
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Class used by CommandLine package when parsing the command line arguments.
|
/// Class used by CommandLine package when parsing the command line arguments.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class StartupOptions
|
public class StartupOptions : IStartupOptions
|
||||||
{
|
{
|
||||||
[Option('d', "datadir", Required = false, HelpText = "Path to use for the data folder (databases files etc.).")]
|
[Option('d', "datadir", Required = false, HelpText = "Path to use for the data folder (databases files etc.).")]
|
||||||
public string PathData { get; set; }
|
public string DataDir { get; set; }
|
||||||
|
|
||||||
[Option('c', "configdir", Required = false, HelpText = "Path to use for config data (user policies and puctures).")]
|
[Option('c', "configdir", Required = false, HelpText = "Path to use for config data (user policies and puctures).")]
|
||||||
public string PathConfig { get; set; }
|
public string ConfigDir { get; set; }
|
||||||
|
|
||||||
[Option('l', "logdir", Required = false, HelpText = "Path to use for writing log files.")]
|
[Option('l', "logdir", Required = false, HelpText = "Path to use for writing log files.")]
|
||||||
public string PathLog { get; set; }
|
public string LogDir { get; set; }
|
||||||
|
|
||||||
|
|
||||||
[Option("ffmpeg", Required = false, HelpText = "Path to external FFmpeg exe to use in place of built-in.")]
|
[Option("ffmpeg", Required = false, HelpText = "Path to external FFmpeg exe to use in place of built-in.")]
|
||||||
public string FFmpeg { get; set; }
|
public string FFmpegPath { get; set; }
|
||||||
|
|
||||||
[Option("ffprobe", Required = false, HelpText = "ffmpeg and ffprobe switches must be supplied together.")]
|
[Option("ffprobe", Required = false, HelpText = "ffmpeg and ffprobe switches must be supplied together.")]
|
||||||
public string FFprobe { get; set; }
|
public string FFprobePath { get; set; }
|
||||||
|
|
||||||
|
|
||||||
[Option("service", Required = false, HelpText = "Run as headless service.")]
|
[Option("service", Required = false, HelpText = "Run as headless service.")]
|
||||||
public bool Service { get; set; }
|
public bool IsService { get; set; }
|
||||||
|
|
||||||
[Option("noautorunwebapp", Required = false, HelpText = "Run headless if startup wizard is complete.")]
|
[Option("noautorunwebapp", Required = false, HelpText = "Run headless if startup wizard is complete.")]
|
||||||
public bool NoAutoRunWebApp { get; set; }
|
public bool AutoRunWebApp { get => !NoautoRunWebApp; set => NoautoRunWebApp = value; }
|
||||||
|
|
||||||
[Option("package-name", Required = false, HelpText = "Used when packaging Jellyfin (example, synology).")]
|
[Option("package-name", Required = false, HelpText = "Used when packaging Jellyfin (example, synology).")]
|
||||||
public string PackageName { get; set; }
|
public string PackageName { get; set; }
|
||||||
|
|
||||||
|
|
||||||
[Option("restartpath", Required = false, HelpText = "Path to reset script.")]
|
[Option("restartpath", Required = false, HelpText = "Path to reset script.")]
|
||||||
public string RestartPath { get; set; }
|
public string RestartPath { get; set; }
|
||||||
|
|
||||||
[Option("restartargs", Required = false, HelpText = "Arguments for restart script.")]
|
[Option("restartargs", Required = false, HelpText = "Arguments for restart script.")]
|
||||||
public string RestartArgs { get; set; }
|
public string RestartArgs { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether to run not run the web app.
|
||||||
|
/// Command line switch is --noautorunwebapp, which we store privately here, but provide inverse (AutoRunWebApp) for users.
|
||||||
|
/// </summary>
|
||||||
|
private bool NoautoRunWebApp { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user