From c27bc3de13f2370fab39267e5f293a0ed4dc3d29 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 29 Jun 2016 21:11:58 -0400 Subject: [PATCH 1/3] add error handling --- MediaBrowser.Server.Startup.Common/FFMpeg/FFMpegLoader.cs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/MediaBrowser.Server.Startup.Common/FFMpeg/FFMpegLoader.cs b/MediaBrowser.Server.Startup.Common/FFMpeg/FFMpegLoader.cs index a4c50d0d8f..39f593310a 100644 --- a/MediaBrowser.Server.Startup.Common/FFMpeg/FFMpegLoader.cs +++ b/MediaBrowser.Server.Startup.Common/FFMpeg/FFMpegLoader.cs @@ -203,13 +203,6 @@ namespace MediaBrowser.Server.Startup.Common.FFMpeg _logger.ErrorException("Error downloading {0}", ex, url); } } - - if (downloadinfo.DownloadUrls.Length == 0) - { - throw new ApplicationException("ffmpeg unvailable. Please install it and start the server with two command line arguments: -ffmpeg \"{PATH}\" and -ffprobe \"{PATH}\""); - } - - throw new ApplicationException("Unable to download required components. Please try again later."); } private void ExtractFFMpeg(FFMpegInstallInfo downloadinfo, string tempFile, string targetFolder) From d15eb5963557e8f1d7b2be449224c00f9a91237a Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 29 Jun 2016 21:19:38 -0400 Subject: [PATCH 2/3] add error handling --- .../FFMpeg/FFMpegLoader.cs | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/MediaBrowser.Server.Startup.Common/FFMpeg/FFMpegLoader.cs b/MediaBrowser.Server.Startup.Common/FFMpeg/FFMpegLoader.cs index 39f593310a..4c5759b567 100644 --- a/MediaBrowser.Server.Startup.Common/FFMpeg/FFMpegLoader.cs +++ b/MediaBrowser.Server.Startup.Common/FFMpeg/FFMpegLoader.cs @@ -60,10 +60,6 @@ namespace MediaBrowser.Server.Startup.Common.FFMpeg var downloadInfo = _ffmpegInstallInfo; var version = downloadInfo.Version; - if (string.Equals(version, "0", StringComparison.OrdinalIgnoreCase)) - { - return new FFMpegInfo(); - } if (string.Equals(version, "path", StringComparison.OrdinalIgnoreCase)) { @@ -75,6 +71,11 @@ namespace MediaBrowser.Server.Startup.Common.FFMpeg }; } + if (string.Equals(version, "0", StringComparison.OrdinalIgnoreCase)) + { + return new FFMpegInfo(); + } + var rootEncoderPath = Path.Combine(_appPaths.ProgramDataPath, "ffmpeg"); var versionedDirectoryPath = Path.Combine(rootEncoderPath, version); @@ -97,7 +98,11 @@ namespace MediaBrowser.Server.Startup.Common.FFMpeg // No older version. Need to download and block until complete if (existingVersion == null) { - await DownloadFFMpeg(downloadInfo, versionedDirectoryPath, progress).ConfigureAwait(false); + var success = await DownloadFFMpeg(downloadInfo, versionedDirectoryPath, progress).ConfigureAwait(false); + if (!success) + { + return new FFMpegInfo(); + } } else { @@ -179,7 +184,7 @@ namespace MediaBrowser.Server.Startup.Common.FFMpeg return null; } - private async Task DownloadFFMpeg(FFMpegInstallInfo downloadinfo, string directory, IProgress progress) + private async Task DownloadFFMpeg(FFMpegInstallInfo downloadinfo, string directory, IProgress progress) { foreach (var url in downloadinfo.DownloadUrls) { @@ -196,13 +201,14 @@ namespace MediaBrowser.Server.Startup.Common.FFMpeg }).ConfigureAwait(false); ExtractFFMpeg(downloadinfo, tempFile, directory); - return; + return true; } catch (Exception ex) { _logger.ErrorException("Error downloading {0}", ex, url); } } + return false; } private void ExtractFFMpeg(FFMpegInstallInfo downloadinfo, string tempFile, string targetFolder) From e74160596df9c47c11baa29e2f6d8ee1eae7f9d4 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 29 Jun 2016 21:23:58 -0400 Subject: [PATCH 3/3] add logging --- MediaBrowser.Server.Startup.Common/ApplicationHost.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs index 4534677ca2..651b0e01f5 100644 --- a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs +++ b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs @@ -335,6 +335,7 @@ namespace MediaBrowser.Server.Startup.Common foreach (var entryPoint in GetExports().ToList()) { var name = entryPoint.GetType().FullName; + Logger.Info("Starting entry point {0}", name); try { entryPoint.Run(); @@ -343,8 +344,9 @@ namespace MediaBrowser.Server.Startup.Common { Logger.ErrorException("Error in {0}", ex, name); } + Logger.Info("Entry point completed: {0}", name); } - Logger.Info("Entry points complete"); + Logger.Info("All entry points have started"); LogManager.RemoveConsoleOutput(); }