mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-05-31 20:24:21 -04:00
add startup error handling
This commit is contained in:
parent
cbeb77c0ad
commit
525f780453
@ -131,7 +131,7 @@ namespace MediaBrowser.Controller.MediaEncoding
|
|||||||
/// <returns>System.String.</returns>
|
/// <returns>System.String.</returns>
|
||||||
string EscapeSubtitleFilterPath(string path);
|
string EscapeSubtitleFilterPath(string path);
|
||||||
|
|
||||||
void Init();
|
Task Init();
|
||||||
|
|
||||||
Task UpdateEncoderPath(string path, string pathType);
|
Task UpdateEncoderPath(string path, string pathType);
|
||||||
}
|
}
|
||||||
|
@ -1,31 +1,29 @@
|
|||||||
using MediaBrowser.Common.Configuration;
|
using System;
|
||||||
using MediaBrowser.Model.Logging;
|
using System.Collections.Generic;
|
||||||
using System;
|
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Collections.Generic;
|
using MediaBrowser.Model.Logging;
|
||||||
using CommonIO;
|
|
||||||
|
|
||||||
namespace MediaBrowser.Server.Startup.Common.FFMpeg
|
namespace MediaBrowser.MediaEncoding.Encoder
|
||||||
{
|
{
|
||||||
public class FFmpegValidator
|
public class EncoderValidator
|
||||||
{
|
{
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly IApplicationPaths _appPaths;
|
|
||||||
private readonly IFileSystem _fileSystem;
|
|
||||||
|
|
||||||
public FFmpegValidator(ILogger logger, IApplicationPaths appPaths, IFileSystem fileSystem)
|
public EncoderValidator(ILogger logger)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_appPaths = appPaths;
|
|
||||||
_fileSystem = fileSystem;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Tuple<List<string>,List<string>> Validate(string encoderPath)
|
public Tuple<List<string>, List<string>> Validate(string encoderPath)
|
||||||
{
|
{
|
||||||
|
_logger.Info("Validating media encoder at {0}", encoderPath);
|
||||||
|
|
||||||
var decoders = GetDecoders(encoderPath);
|
var decoders = GetDecoders(encoderPath);
|
||||||
var encoders = GetEncoders(encoderPath);
|
var encoders = GetEncoders(encoderPath);
|
||||||
|
|
||||||
|
_logger.Info("Encoder validation complete");
|
||||||
|
|
||||||
return new Tuple<List<string>, List<string>>(decoders, encoders);
|
return new Tuple<List<string>, List<string>>(decoders, encoders);
|
||||||
}
|
}
|
||||||
|
|
@ -132,7 +132,20 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Init()
|
public async Task Init()
|
||||||
|
{
|
||||||
|
InitPaths();
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(FFMpegPath))
|
||||||
|
{
|
||||||
|
var result = new EncoderValidator(_logger).Validate(FFMpegPath);
|
||||||
|
|
||||||
|
SetAvailableDecoders(result.Item1);
|
||||||
|
SetAvailableEncoders(result.Item2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void InitPaths()
|
||||||
{
|
{
|
||||||
ConfigureEncoderPaths();
|
ConfigureEncoderPaths();
|
||||||
|
|
||||||
|
@ -71,6 +71,7 @@
|
|||||||
<Compile Include="Encoder\EncodingJob.cs" />
|
<Compile Include="Encoder\EncodingJob.cs" />
|
||||||
<Compile Include="Encoder\EncodingJobFactory.cs" />
|
<Compile Include="Encoder\EncodingJobFactory.cs" />
|
||||||
<Compile Include="Encoder\EncodingUtils.cs" />
|
<Compile Include="Encoder\EncodingUtils.cs" />
|
||||||
|
<Compile Include="Encoder\EncoderValidator.cs" />
|
||||||
<Compile Include="Encoder\JobLogger.cs" />
|
<Compile Include="Encoder\JobLogger.cs" />
|
||||||
<Compile Include="Encoder\MediaEncoder.cs" />
|
<Compile Include="Encoder\MediaEncoder.cs" />
|
||||||
<Compile Include="Encoder\VideoEncoder.cs" />
|
<Compile Include="Encoder\VideoEncoder.cs" />
|
||||||
|
@ -44,11 +44,12 @@ namespace MediaBrowser.Server.Implementations.Connect
|
|||||||
LoadCachedAddress();
|
LoadCachedAddress();
|
||||||
|
|
||||||
_timer = new PeriodicTimer(TimerCallback, null, TimeSpan.FromSeconds(5), TimeSpan.FromHours(3));
|
_timer = new PeriodicTimer(TimerCallback, null, TimeSpan.FromSeconds(5), TimeSpan.FromHours(3));
|
||||||
|
((ConnectManager)_connectManager).Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly string[] _ipLookups =
|
private readonly string[] _ipLookups =
|
||||||
{
|
{
|
||||||
"http://bot.whatismyipaddress.com",
|
"http://bot.whatismyipaddress.com",
|
||||||
"https://connect.emby.media/service/ip"
|
"https://connect.emby.media/service/ip"
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -78,17 +79,18 @@ namespace MediaBrowser.Server.Implementations.Connect
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If this produced an ipv6 address, try again
|
// If this produced an ipv6 address, try again
|
||||||
if (validIpAddress == null || validIpAddress.AddressFamily == AddressFamily.InterNetworkV6)
|
if (validIpAddress != null && validIpAddress.AddressFamily == AddressFamily.InterNetworkV6)
|
||||||
{
|
{
|
||||||
foreach (var ipLookupUrl in _ipLookups)
|
foreach (var ipLookupUrl in _ipLookups)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
validIpAddress = await GetIpAddress(ipLookupUrl, true).ConfigureAwait(false);
|
var newAddress = await GetIpAddress(ipLookupUrl, true).ConfigureAwait(false);
|
||||||
|
|
||||||
// Try to find the ipv4 address, if present
|
// Try to find the ipv4 address, if present
|
||||||
if (validIpAddress.AddressFamily == AddressFamily.InterNetwork)
|
if (newAddress.AddressFamily == AddressFamily.InterNetwork)
|
||||||
{
|
{
|
||||||
|
validIpAddress = newAddress;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -139,11 +139,14 @@ namespace MediaBrowser.Server.Implementations.Connect
|
|||||||
_securityManager = securityManager;
|
_securityManager = securityManager;
|
||||||
_fileSystem = fileSystem;
|
_fileSystem = fileSystem;
|
||||||
|
|
||||||
_config.ConfigurationUpdated += _config_ConfigurationUpdated;
|
|
||||||
|
|
||||||
LoadCachedData();
|
LoadCachedData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal void Start()
|
||||||
|
{
|
||||||
|
_config.ConfigurationUpdated += _config_ConfigurationUpdated;
|
||||||
|
}
|
||||||
|
|
||||||
internal void OnWanAddressResolved(IPAddress address)
|
internal void OnWanAddressResolved(IPAddress address)
|
||||||
{
|
{
|
||||||
DiscoveredWanIpAddress = address;
|
DiscoveredWanIpAddress = address;
|
||||||
|
@ -322,7 +322,7 @@ namespace MediaBrowser.Server.Startup.Common
|
|||||||
|
|
||||||
await base.RunStartupTasks().ConfigureAwait(false);
|
await base.RunStartupTasks().ConfigureAwait(false);
|
||||||
|
|
||||||
InitMediaEncoder();
|
await MediaEncoder.Init().ConfigureAwait(false);
|
||||||
|
|
||||||
Logger.Info("ServerId: {0}", SystemId);
|
Logger.Info("ServerId: {0}", SystemId);
|
||||||
Logger.Info("Core startup complete");
|
Logger.Info("Core startup complete");
|
||||||
@ -350,20 +350,6 @@ namespace MediaBrowser.Server.Startup.Common
|
|||||||
LogManager.RemoveConsoleOutput();
|
LogManager.RemoveConsoleOutput();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitMediaEncoder()
|
|
||||||
{
|
|
||||||
MediaEncoder.Init();
|
|
||||||
|
|
||||||
Task.Run(() =>
|
|
||||||
{
|
|
||||||
var result = new FFmpegValidator(Logger, ApplicationPaths, FileSystemManager).Validate(MediaEncoder.EncoderPath);
|
|
||||||
|
|
||||||
var mediaEncoder = (MediaEncoder) MediaEncoder;
|
|
||||||
mediaEncoder.SetAvailableDecoders(result.Item1);
|
|
||||||
mediaEncoder.SetAvailableEncoders(result.Item2);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public override Task Init(IProgress<double> progress)
|
public override Task Init(IProgress<double> progress)
|
||||||
{
|
{
|
||||||
HttpPort = ServerConfigurationManager.Configuration.HttpServerPortNumber;
|
HttpPort = ServerConfigurationManager.Configuration.HttpServerPortNumber;
|
||||||
|
@ -68,7 +68,6 @@
|
|||||||
<Compile Include="FFMpeg\FFMpegLoader.cs" />
|
<Compile Include="FFMpeg\FFMpegLoader.cs" />
|
||||||
<Compile Include="FFMpeg\FFMpegInstallInfo.cs" />
|
<Compile Include="FFMpeg\FFMpegInstallInfo.cs" />
|
||||||
<Compile Include="FFMpeg\FFMpegInfo.cs" />
|
<Compile Include="FFMpeg\FFMpegInfo.cs" />
|
||||||
<Compile Include="FFMpeg\FFmpegValidator.cs" />
|
|
||||||
<Compile Include="INativeApp.cs" />
|
<Compile Include="INativeApp.cs" />
|
||||||
<Compile Include="MbLinkShortcutHandler.cs" />
|
<Compile Include="MbLinkShortcutHandler.cs" />
|
||||||
<Compile Include="Migrations\CollectionGroupingMigration.cs" />
|
<Compile Include="Migrations\CollectionGroupingMigration.cs" />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user