diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs index 673798294c..02308f79f5 100644 --- a/Emby.Server.Implementations/ApplicationHost.cs +++ b/Emby.Server.Implementations/ApplicationHost.cs @@ -1,5 +1,4 @@ -using Emby.Common.Implementations; -using Emby.Common.Implementations.Serialization; +using Emby.Common.Implementations.Serialization; using Emby.Dlna; using Emby.Dlna.ConnectionManager; using Emby.Dlna.ContentDirectory; @@ -8,12 +7,16 @@ using Emby.Dlna.MediaReceiverRegistrar; using Emby.Dlna.Ssdp; using Emby.Drawing; using Emby.Photos; +using Emby.Server.Core.Cryptography; using Emby.Server.Implementations.Activity; +using Emby.Server.Implementations.Archiving; using Emby.Server.Implementations.Channels; using Emby.Server.Implementations.Collections; using Emby.Server.Implementations.Configuration; +using Emby.Server.Implementations.Cryptography; using Emby.Server.Implementations.Data; using Emby.Server.Implementations.Devices; +using Emby.Server.Implementations.Diagnostics; using Emby.Server.Implementations.Dto; using Emby.Server.Implementations.FFMpeg; using Emby.Server.Implementations.HttpServer; @@ -23,14 +26,20 @@ using Emby.Server.Implementations.Library; using Emby.Server.Implementations.LiveTv; using Emby.Server.Implementations.Localization; using Emby.Server.Implementations.MediaEncoder; -using Emby.Server.Implementations.Migrations; +using Emby.Server.Implementations.Net; using Emby.Server.Implementations.Notifications; using Emby.Server.Implementations.Playlists; +using Emby.Server.Implementations.Reflection; +using Emby.Server.Implementations.ScheduledTasks; using Emby.Server.Implementations.Security; +using Emby.Server.Implementations.Serialization; using Emby.Server.Implementations.Session; using Emby.Server.Implementations.Social; +using Emby.Server.Implementations.Threading; using Emby.Server.Implementations.TV; using Emby.Server.Implementations.Updates; +using Emby.Server.Implementations.Xml; +using Emby.Server.MediaEncoding.Subtitles; using MediaBrowser.Api; using MediaBrowser.Common; using MediaBrowser.Common.Configuration; @@ -52,9 +61,6 @@ using MediaBrowser.Controller.Dlna; using MediaBrowser.Controller.Drawing; using MediaBrowser.Controller.Dto; using MediaBrowser.Controller.Entities; -using MediaBrowser.Controller.Entities.Audio; -using MediaBrowser.Controller.Entities.Movies; -using MediaBrowser.Controller.Entities.TV; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.LiveTv; using MediaBrowser.Controller.MediaEncoding; @@ -72,10 +78,13 @@ using MediaBrowser.Controller.Subtitles; using MediaBrowser.Controller.Sync; using MediaBrowser.Controller.TV; using MediaBrowser.LocalMetadata.Savers; +using MediaBrowser.MediaEncoding.BdInfo; using MediaBrowser.Model.Activity; using MediaBrowser.Model.Configuration; +using MediaBrowser.Model.Cryptography; using MediaBrowser.Model.Diagnostics; using MediaBrowser.Model.Dlna; +using MediaBrowser.Model.Events; using MediaBrowser.Model.Globalization; using MediaBrowser.Model.IO; using MediaBrowser.Model.Logging; @@ -87,7 +96,9 @@ using MediaBrowser.Model.Serialization; using MediaBrowser.Model.Services; using MediaBrowser.Model.Social; using MediaBrowser.Model.System; +using MediaBrowser.Model.Tasks; using MediaBrowser.Model.Text; +using MediaBrowser.Model.Threading; using MediaBrowser.Model.Updates; using MediaBrowser.Model.Xml; using MediaBrowser.Providers.Chapters; @@ -97,7 +108,6 @@ using MediaBrowser.WebDashboard.Api; using MediaBrowser.XbmcMetadata.Providers; using OpenSubtitlesHandler; using ServiceStack; -using SocketHttpListener.Primitives; using System; using System.Collections.Concurrent; using System.Collections.Generic; @@ -111,22 +121,6 @@ using System.Security.Cryptography.X509Certificates; using System.Text; using System.Threading; using System.Threading.Tasks; -using Emby.Server.Core.Cryptography; -using Emby.Server.Implementations.Archiving; -using Emby.Server.Implementations.Cryptography; -using Emby.Server.Implementations.Diagnostics; -using Emby.Server.Implementations.Net; -using Emby.Server.Implementations.Reflection; -using Emby.Server.Implementations.ScheduledTasks; -using Emby.Server.Implementations.Serialization; -using Emby.Server.Implementations.Threading; -using Emby.Server.Implementations.Xml; -using Emby.Server.MediaEncoding.Subtitles; -using MediaBrowser.MediaEncoding.BdInfo; -using MediaBrowser.Model.Cryptography; -using MediaBrowser.Model.Events; -using MediaBrowser.Model.Tasks; -using MediaBrowser.Model.Threading; using StringExtensions = MediaBrowser.Controller.Extensions.StringExtensions; using X509Certificate = System.Security.Cryptography.X509Certificates.X509Certificate; @@ -135,7 +129,7 @@ namespace Emby.Server.Implementations /// /// Class CompositionRoot /// - public abstract class ApplicationHost : IServerApplicationHost, IDependencyContainer + public abstract class ApplicationHost : IServerApplicationHost, IDependencyContainer, IDisposable { /// /// Gets a value indicating whether this instance can self restart. @@ -171,6 +165,8 @@ namespace Emby.Server.Implementations /// true if this instance has pending application restart; otherwise, false. public bool HasPendingRestart { get; private set; } + public bool IsShuttingDown { get; private set; } + /// /// Gets or sets the logger. /// @@ -367,7 +363,7 @@ namespace Emby.Server.Implementations protected IAuthService AuthService { get; private set; } protected readonly StartupOptions StartupOptions; - private readonly string _releaseAssetFilename; + protected readonly string ReleaseAssetFilename; internal IPowerManagement PowerManagement { get; private set; } internal IImageEncoder ImageEncoder { get; private set; } @@ -420,7 +416,7 @@ namespace Emby.Server.Implementations Logger = LogManager.GetLogger("App"); StartupOptions = options; - _releaseAssetFilename = releaseAssetFilename; + ReleaseAssetFilename = releaseAssetFilename; PowerManagement = powerManagement; ImageEncoder = imageEncoder; @@ -1755,25 +1751,35 @@ namespace Emby.Server.Implementations /// /// Restarts this instance. /// - public async Task Restart() + public void Restart() { if (!CanSelfRestart) { throw new PlatformNotSupportedException("The server is unable to self-restart. Please restart manually."); } - try + if (IsShuttingDown) { - await SessionManager.SendServerRestartNotification(CancellationToken.None).ConfigureAwait(false); + return; } - catch (Exception ex) + + IsShuttingDown = true; + + Task.Run(async () => { - Logger.ErrorException("Error sending server restart notification", ex); - } + try + { + await SessionManager.SendServerRestartNotification(CancellationToken.None).ConfigureAwait(false); + } + catch (Exception ex) + { + Logger.ErrorException("Error sending server restart notification", ex); + } - Logger.Info("Calling RestartInternal"); + Logger.Info("Calling RestartInternal"); - RestartInternal(); + RestartInternal(); + }); } protected abstract void RestartInternal(); @@ -1880,6 +1886,7 @@ namespace Emby.Server.Implementations return new SystemInfo { HasPendingRestart = HasPendingRestart, + IsShuttingDown = IsShuttingDown, Version = ApplicationVersion.ToString(), WebSocketPortNumber = HttpPort, FailedPluginAssemblies = FailedAssemblies.ToArray(), @@ -2107,6 +2114,13 @@ namespace Emby.Server.Implementations /// public async Task Shutdown() { + if (IsShuttingDown) + { + return; + } + + IsShuttingDown = true; + try { await SessionManager.SendServerShutdownNotification(CancellationToken.None).ConfigureAwait(false); @@ -2185,22 +2199,29 @@ namespace Emby.Server.Implementations /// Task{CheckForUpdateResult}. public async Task CheckForApplicationUpdate(CancellationToken cancellationToken, IProgress progress) { - var cacheLength = TimeSpan.FromHours(1); + var cacheLength = TimeSpan.FromMinutes(5); var updateLevel = SystemUpdateLevel; - if (updateLevel != PackageVersionClass.Release) - { - cacheLength = TimeSpan.FromMinutes(5); - } - - var result = await new GithubUpdater(HttpClient, JsonSerializer).CheckForUpdateResult("MediaBrowser", "Emby", ApplicationVersion, updateLevel, _releaseAssetFilename, - "MBServer", "Mbserver.zip", cacheLength, cancellationToken).ConfigureAwait(false); + var result = await new GithubUpdater(HttpClient, JsonSerializer).CheckForUpdateResult("MediaBrowser", + "Emby", + ApplicationVersion, + updateLevel, + ReleaseAssetFilename, + "MBServer", + UpdateTargetFileName, + cacheLength, + cancellationToken).ConfigureAwait(false); HasUpdateAvailable = result.IsUpdateAvailable; return result; } + protected virtual string UpdateTargetFileName + { + get { return "Mbserver.zip"; } + } + /// /// Updates the application. /// diff --git a/MediaBrowser.Api/System/SystemService.cs b/MediaBrowser.Api/System/SystemService.cs index 37613c1c81..d850b2ce72 100644 --- a/MediaBrowser.Api/System/SystemService.cs +++ b/MediaBrowser.Api/System/SystemService.cs @@ -192,11 +192,7 @@ namespace MediaBrowser.Api.System /// The request. public void Post(RestartApplication request) { - Task.Run(async () => - { - await Task.Delay(100).ConfigureAwait(false); - await _appHost.Restart().ConfigureAwait(false); - }); + _appHost.Restart(); } /// diff --git a/MediaBrowser.Common/IApplicationHost.cs b/MediaBrowser.Common/IApplicationHost.cs index 2b5ae67992..dc0c9ac9bd 100644 --- a/MediaBrowser.Common/IApplicationHost.cs +++ b/MediaBrowser.Common/IApplicationHost.cs @@ -42,6 +42,8 @@ namespace MediaBrowser.Common /// true if this instance has pending kernel reload; otherwise, false. bool HasPendingRestart { get; } + bool IsShuttingDown { get; } + /// /// Gets a value indicating whether this instance can self restart. /// @@ -57,11 +59,11 @@ namespace MediaBrowser.Common /// Notifies the pending restart. /// void NotifyPendingRestart(); - + /// /// Restarts this instance. /// - Task Restart(); + void Restart(); /// /// Gets the application version. diff --git a/MediaBrowser.Model/System/SystemInfo.cs b/MediaBrowser.Model/System/SystemInfo.cs index fce9dea4f1..f9f3bf52e5 100644 --- a/MediaBrowser.Model/System/SystemInfo.cs +++ b/MediaBrowser.Model/System/SystemInfo.cs @@ -36,6 +36,8 @@ namespace MediaBrowser.Model.System /// true if this instance has pending restart; otherwise, false. public bool HasPendingRestart { get; set; } + public bool IsShuttingDown { get; set; } + /// /// Gets or sets a value indicating whether [supports library monitor]. /// diff --git a/MediaBrowser.Server.Mono/Program.cs b/MediaBrowser.Server.Mono/Program.cs index 98ad8bb026..c53a80ae63 100644 --- a/MediaBrowser.Server.Mono/Program.cs +++ b/MediaBrowser.Server.Mono/Program.cs @@ -11,6 +11,7 @@ using System.Net.Security; using System.Reflection; using System.Text.RegularExpressions; using System.Threading.Tasks; +using Emby.Drawing; using Emby.Server.Core.Cryptography; using Emby.Server.Core; using Emby.Server.Implementations; @@ -18,6 +19,7 @@ using Emby.Server.Implementations.EnvironmentInfo; using Emby.Server.Implementations.IO; using Emby.Server.Implementations.Logging; using Emby.Server.Implementations.Networking; +using MediaBrowser.Controller; using MediaBrowser.Model.IO; using MediaBrowser.Model.System; using Mono.Unix.Native; @@ -28,10 +30,10 @@ namespace MediaBrowser.Server.Mono { public class MainClass { - private static ApplicationHost _appHost; - private static ILogger _logger; private static IFileSystem FileSystem; + private static IServerApplicationPaths _appPaths; + private static ILogManager _logManager; private static readonly TaskCompletionSource ApplicationTaskCompletionSource = new TaskCompletionSource(); private static bool _restartOnShutdown; @@ -49,9 +51,12 @@ namespace MediaBrowser.Server.Mono var customProgramDataPath = options.GetOption("-programdata"); var appPaths = CreateApplicationPaths(applicationPath, customProgramDataPath); + _appPaths = appPaths; using (var logManager = new SimpleLogManager(appPaths.LogDirectoryPath, "server")) { + _logManager = logManager; + logManager.ReloadLogger(LogSeverity.Info); logManager.AddConsoleOutput(); @@ -68,7 +73,6 @@ namespace MediaBrowser.Server.Mono finally { _logger.Info("Disposing app host"); - _appHost.Dispose(); if (_restartOnShutdown) { @@ -106,40 +110,41 @@ namespace MediaBrowser.Server.Mono FileSystem = fileSystem; - var imageEncoder = ImageEncoderHelper.GetImageEncoder(_logger, logManager, fileSystem, options, () => _appHost.HttpClient, appPaths, environmentInfo); - - _appHost = new MonoAppHost(appPaths, + using (var appHost = new MonoAppHost(appPaths, logManager, options, fileSystem, new PowerManagement(), "emby.mono.zip", environmentInfo, - imageEncoder, + new NullImageEncoder(), new SystemEvents(logManager.GetLogger("SystemEvents")), - new NetworkManager(logManager.GetLogger("NetworkManager"))); - - if (options.ContainsOption("-v")) + new NetworkManager(logManager.GetLogger("NetworkManager")))) { - Console.WriteLine(_appHost.ApplicationVersion.ToString()); - return; - } + appHost.ImageProcessor.ImageEncoder = ImageEncoderHelper.GetImageEncoder(_logger, logManager, fileSystem, options, () => appHost.HttpClient, appPaths, environmentInfo); - Console.WriteLine("appHost.Init"); + if (options.ContainsOption("-v")) + { + Console.WriteLine(appHost.ApplicationVersion.ToString()); + return; + } - var initProgress = new Progress(); + Console.WriteLine("appHost.Init"); - var task = _appHost.Init(initProgress); - Task.WaitAll(task); + var initProgress = new Progress(); - Console.WriteLine("Running startup tasks"); + var task = appHost.Init(initProgress); + Task.WaitAll(task); - task = _appHost.RunStartupTasks(); - Task.WaitAll(task); + Console.WriteLine("Running startup tasks"); - task = ApplicationTaskCompletionSource.Task; + task = appHost.RunStartupTasks(); + Task.WaitAll(task); - Task.WaitAll(task); + task = ApplicationTaskCompletionSource.Task; + + Task.WaitAll(task); + } } private static MonoEnvironmentInfo GetEnvironmentInfo() @@ -231,7 +236,7 @@ namespace MediaBrowser.Server.Mono { var exception = (Exception)e.ExceptionObject; - new UnhandledExceptionWriter(_appHost.ServerConfigurationManager.ApplicationPaths, _logger, _appHost.LogManager, FileSystem, new ConsoleLogger()).Log(exception); + new UnhandledExceptionWriter(_appPaths, _logger, _logManager, FileSystem, new ConsoleLogger()).Log(exception); if (!Debugger.IsAttached) { diff --git a/MediaBrowser.ServerApplication/MainStartup.cs b/MediaBrowser.ServerApplication/MainStartup.cs index 31acd18200..3fe9c5aa7e 100644 --- a/MediaBrowser.ServerApplication/MainStartup.cs +++ b/MediaBrowser.ServerApplication/MainStartup.cs @@ -25,6 +25,7 @@ using Emby.Server.Implementations.EnvironmentInfo; using Emby.Server.Implementations.IO; using Emby.Server.Implementations.Logging; using MediaBrowser.Common.Net; +using MediaBrowser.Controller; using MediaBrowser.Model.IO; using SystemEvents = Emby.Server.Implementations.SystemEvents; @@ -32,13 +33,13 @@ namespace MediaBrowser.ServerApplication { public class MainStartup { - private static ApplicationHost _appHost; + private static IServerApplicationPaths _appPaths; + private static ILogManager _logManager; private static ILogger _logger; public static bool IsRunningAsService = false; private static bool _canRestartService = false; - private static bool _appHostDisposed; [DllImport("kernel32.dll", SetLastError = true)] static extern bool SetDllDirectory(string lpPathName); @@ -46,6 +47,7 @@ namespace MediaBrowser.ServerApplication public static string ApplicationPath; private static IFileSystem FileSystem; + private static bool _restartOnShutdown; /// /// Defines the entry point of the application. @@ -71,9 +73,12 @@ namespace MediaBrowser.ServerApplication SQLitePCL.raw.SetProvider(new SQLitePCL.SQLite3Provider_sqlite3()); var appPaths = CreateApplicationPaths(ApplicationPath, IsRunningAsService); + _appPaths = appPaths; using (var logManager = new SimpleLogManager(appPaths.LogDirectoryPath, "server")) { + _logManager = logManager; + logManager.ReloadLogger(LogSeverity.Debug); logManager.AddConsoleOutput(); @@ -129,17 +134,28 @@ namespace MediaBrowser.ServerApplication return; } - try - { - RunApplication(appPaths, logManager, IsRunningAsService, options); - } - finally + RunApplication(appPaths, logManager, IsRunningAsService, options); + + logger.Info("Shutdown complete"); + + if (_restartOnShutdown) { - OnServiceShutdown(); + logger.Info("Starting new server process"); + var restartCommandLine = GetRestartCommandLine(); + + Process.Start(restartCommandLine.Item1, restartCommandLine.Item2); } } } + public static Tuple GetRestartCommandLine() + { + var currentProcess = Process.GetCurrentProcess(); + var processModulePath = currentProcess.MainModule.FileName; + + return new Tuple(processModulePath, Environment.CommandLine); + } + /// /// Determines whether [is already running] [the specified current process]. /// @@ -314,7 +330,7 @@ namespace MediaBrowser.ServerApplication FileSystem = fileSystem; - _appHost = new WindowsAppHost(appPaths, + using (var appHost = new WindowsAppHost(appPaths, logManager, options, fileSystem, @@ -323,60 +339,59 @@ namespace MediaBrowser.ServerApplication environmentInfo, new NullImageEncoder(), new SystemEvents(logManager.GetLogger("SystemEvents")), - new Networking.NetworkManager(logManager.GetLogger("NetworkManager"))); - - var initProgress = new Progress(); - - if (!runService) + new Networking.NetworkManager(logManager.GetLogger("NetworkManager")))) { - if (!options.ContainsOption("-nosplash")) ShowSplashScreen(_appHost.ApplicationVersion, initProgress, logManager.GetLogger("Splash")); + var initProgress = new Progress(); - // Not crazy about this but it's the only way to suppress ffmpeg crash dialog boxes - SetErrorMode(ErrorModes.SEM_FAILCRITICALERRORS | ErrorModes.SEM_NOALIGNMENTFAULTEXCEPT | - ErrorModes.SEM_NOGPFAULTERRORBOX | ErrorModes.SEM_NOOPENFILEERRORBOX); - } + if (!runService) + { + if (!options.ContainsOption("-nosplash")) ShowSplashScreen(appHost.ApplicationVersion, initProgress, logManager.GetLogger("Splash")); - var task = _appHost.Init(initProgress); - Task.WaitAll(task); + // Not crazy about this but it's the only way to suppress ffmpeg crash dialog boxes + SetErrorMode(ErrorModes.SEM_FAILCRITICALERRORS | ErrorModes.SEM_NOALIGNMENTFAULTEXCEPT | + ErrorModes.SEM_NOGPFAULTERRORBOX | ErrorModes.SEM_NOOPENFILEERRORBOX); + } - if (!runService) - { - task = InstallVcredist2013IfNeeded(_appHost, _logger); + var task = appHost.Init(initProgress); Task.WaitAll(task); - // needed by skia - task = InstallVcredist2015IfNeeded(_appHost, _logger); - Task.WaitAll(task); - } + if (!runService) + { + task = InstallVcredist2013IfNeeded(appHost.HttpClient, _logger); + Task.WaitAll(task); - // set image encoder here - _appHost.ImageProcessor.ImageEncoder = ImageEncoderHelper.GetImageEncoder(_logger, logManager, fileSystem, options, () => _appHost.HttpClient, appPaths); + // needed by skia + task = InstallVcredist2015IfNeeded(appHost.HttpClient, _logger); + Task.WaitAll(task); + } - task = task.ContinueWith(new Action(a => _appHost.RunStartupTasks()), TaskContinuationOptions.OnlyOnRanToCompletion | TaskContinuationOptions.AttachedToParent); + // set image encoder here + appHost.ImageProcessor.ImageEncoder = ImageEncoderHelper.GetImageEncoder(_logger, logManager, fileSystem, options, () => appHost.HttpClient, appPaths); - if (runService) - { - StartService(logManager); - } - else - { - Task.WaitAll(task); + task = task.ContinueWith(new Action(a => appHost.RunStartupTasks()), TaskContinuationOptions.OnlyOnRanToCompletion | TaskContinuationOptions.AttachedToParent); - Microsoft.Win32.SystemEvents.SessionSwitch += SystemEvents_SessionSwitch; + if (runService) + { + StartService(logManager); + } + else + { + Task.WaitAll(task); - HideSplashScreen(); + HideSplashScreen(); - ShowTrayIcon(); + ShowTrayIcon(appHost); + } } } private static ServerNotifyIcon _serverNotifyIcon; private static TaskScheduler _mainTaskScheduler; - private static void ShowTrayIcon() + private static void ShowTrayIcon(ApplicationHost appHost) { //Application.EnableVisualStyles(); //Application.SetCompatibleTextRenderingDefault(false); - _serverNotifyIcon = new ServerNotifyIcon(_appHost.LogManager, _appHost, _appHost.ServerConfigurationManager, _appHost.LocalizationManager); + _serverNotifyIcon = new ServerNotifyIcon(appHost.LogManager, appHost, appHost.ServerConfigurationManager, appHost.LocalizationManager); _mainTaskScheduler = TaskScheduler.FromCurrentSynchronizationContext(); Application.Run(); } @@ -413,14 +428,6 @@ namespace MediaBrowser.ServerApplication } } - static void SystemEvents_SessionSwitch(object sender, SessionSwitchEventArgs e) - { - if (e.Reason == SessionSwitchReason.SessionLogon) - { - BrowserLauncher.OpenDashboard(_appHost); - } - } - public static void Invoke(Action action) { if (IsRunningAsService) @@ -452,14 +459,6 @@ namespace MediaBrowser.ServerApplication /// The instance containing the event data. static void service_Disposed(object sender, EventArgs e) { - OnServiceShutdown(); - } - - private static void OnServiceShutdown() - { - _logger.Info("Shutting down"); - - DisposeAppHost(); } /// @@ -562,7 +561,7 @@ namespace MediaBrowser.ServerApplication { var exception = (Exception)e.ExceptionObject; - new UnhandledExceptionWriter(_appHost.ServerConfigurationManager.ApplicationPaths, _logger, _appHost.LogManager, FileSystem, new ConsoleLogger()).Log(exception); + new UnhandledExceptionWriter(_appPaths, _logger, _logManager, FileSystem, new ConsoleLogger()).Log(exception); if (!IsRunningAsService) { @@ -623,45 +622,22 @@ namespace MediaBrowser.ServerApplication } else { - DisposeAppHost(); - ShutdownWindowsApplication(); } } public static void Restart() { - DisposeAppHost(); - if (IsRunningAsService) { - RestartWindowsService(); } else { - //_logger.Info("Hiding server notify icon"); - //_serverNotifyIcon.Visible = false; - - _logger.Info("Starting new instance"); - //Application.Restart(); - Process.Start(ApplicationPath); - + _restartOnShutdown = true; ShutdownWindowsApplication(); } } - private static void DisposeAppHost() - { - if (!_appHostDisposed) - { - _logger.Info("Disposing app host"); - - _appHostDisposed = true; - _appHost.Dispose(); - _logger.Info("App host dispose complete"); - } - } - private static void ShutdownWindowsApplication() { if (_serverNotifyIcon != null) @@ -671,9 +647,7 @@ namespace MediaBrowser.ServerApplication } _logger.Info("Calling Application.Exit"); - //Application.Exit(); - - Environment.Exit(0); + Application.Exit(); } private static void ShutdownWindowsService() @@ -689,23 +663,7 @@ namespace MediaBrowser.ServerApplication } } - private static void RestartWindowsService() - { - _logger.Info("Restarting background service"); - - var startInfo = new ProcessStartInfo - { - FileName = "cmd.exe", - CreateNoWindow = true, - WindowStyle = ProcessWindowStyle.Hidden, - Verb = "runas", - ErrorDialog = false, - Arguments = String.Format("/c sc stop {0} & sc start {0} & sc start {0}", BackgroundService.GetExistingServiceName()) - }; - Process.Start(startInfo); - } - - private static async Task InstallVcredist2013IfNeeded(ApplicationHost appHost, ILogger logger) + private static async Task InstallVcredist2013IfNeeded(IHttpClient httpClient, ILogger logger) { // Reference // http://stackoverflow.com/questions/12206314/detect-if-visual-c-redistributable-for-visual-studio-2012-is-installed @@ -737,7 +695,7 @@ namespace MediaBrowser.ServerApplication try { - await InstallVcredist(GetVcredist2013Url()).ConfigureAwait(false); + await InstallVcredist(GetVcredist2013Url(), httpClient).ConfigureAwait(false); } catch (Exception ex) { @@ -757,7 +715,7 @@ namespace MediaBrowser.ServerApplication return "https://github.com/MediaBrowser/Emby.Resources/raw/master/vcredist2013/vcredist_x86.exe"; } - private static async Task InstallVcredist2015IfNeeded(ApplicationHost appHost, ILogger logger) + private static async Task InstallVcredist2015IfNeeded(IHttpClient httpClient, ILogger logger) { // Reference // http://stackoverflow.com/questions/12206314/detect-if-visual-c-redistributable-for-visual-studio-2012-is-installed @@ -813,7 +771,7 @@ namespace MediaBrowser.ServerApplication try { - await InstallVcredist(GetVcredist2015Url()).ConfigureAwait(false); + await InstallVcredist(GetVcredist2015Url(), httpClient).ConfigureAwait(false); } catch (Exception ex) { @@ -833,10 +791,8 @@ namespace MediaBrowser.ServerApplication return "https://github.com/MediaBrowser/Emby.Resources/raw/master/vcredist2015/vc_redist.x86.exe"; } - private async static Task InstallVcredist(string url) + private async static Task InstallVcredist(string url, IHttpClient httpClient) { - var httpClient = _appHost.HttpClient; - var tmp = await httpClient.GetTempFile(new HttpRequestOptions { Url = url, diff --git a/SharedVersion.cs b/SharedVersion.cs index 93d7c2e196..2de4c7944b 100644 --- a/SharedVersion.cs +++ b/SharedVersion.cs @@ -1,3 +1,3 @@ using System.Reflection; -[assembly: AssemblyVersion("3.2.30.10")] +[assembly: AssemblyVersion("3.2.30.11")]