From 3f1cafdc814c6d0ef866f1c68dcb4dd1034099ec Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 6 Oct 2013 20:49:33 -0400 Subject: [PATCH] updated nuget --- .../BaseApplicationHost.cs | 2 +- .../WebSocket/AlchemyServer.cs | 13 ++----- MediaBrowser.ServerApplication/MainStartup.cs | 36 +++++-------------- Nuget/MediaBrowser.Common.Internal.nuspec | 4 +-- Nuget/MediaBrowser.Common.nuspec | 2 +- Nuget/MediaBrowser.Server.Core.nuspec | 4 +-- 6 files changed, 17 insertions(+), 44 deletions(-) diff --git a/MediaBrowser.Common.Implementations/BaseApplicationHost.cs b/MediaBrowser.Common.Implementations/BaseApplicationHost.cs index 9c77b8627..e7a9c00c6 100644 --- a/MediaBrowser.Common.Implementations/BaseApplicationHost.cs +++ b/MediaBrowser.Common.Implementations/BaseApplicationHost.cs @@ -215,7 +215,7 @@ namespace MediaBrowser.Common.Implementations try { // Increase the max http request limit - ServicePointManager.DefaultConnectionLimit = Math.Min(48, ServicePointManager.DefaultConnectionLimit); + ServicePointManager.DefaultConnectionLimit = Math.Max(48, ServicePointManager.DefaultConnectionLimit); } catch (Exception ex) { diff --git a/MediaBrowser.Server.Implementations/WebSocket/AlchemyServer.cs b/MediaBrowser.Server.Implementations/WebSocket/AlchemyServer.cs index 251083dc2..8be35071a 100644 --- a/MediaBrowser.Server.Implementations/WebSocket/AlchemyServer.cs +++ b/MediaBrowser.Server.Implementations/WebSocket/AlchemyServer.cs @@ -50,8 +50,6 @@ namespace MediaBrowser.Server.Implementations.WebSocket /// The port. public int Port { get; private set; } - private bool _hasStarted; - /// /// Starts the specified port number. /// @@ -69,8 +67,6 @@ namespace MediaBrowser.Server.Implementations.WebSocket }; WebSocketServer.Start(); - - _hasStarted = true; } catch (Exception ex) { @@ -141,14 +137,9 @@ namespace MediaBrowser.Server.Implementations.WebSocket { if (WebSocketServer != null) { - if (_hasStarted) - { - _logger.Debug("Stopping alchemy server"); - WebSocketServer.Stop(); - } - + // Calling dispose will also call stop _logger.Debug("Disposing alchemy server"); - WebSocketServer.Dispose(); + WebSocketServer.Stop(); WebSocketServer = null; } } diff --git a/MediaBrowser.ServerApplication/MainStartup.cs b/MediaBrowser.ServerApplication/MainStartup.cs index 577f5ea38..e69d46661 100644 --- a/MediaBrowser.ServerApplication/MainStartup.cs +++ b/MediaBrowser.ServerApplication/MainStartup.cs @@ -26,8 +26,6 @@ namespace MediaBrowser.ServerApplication private static ILogger _logger; - private static bool _isRestarting = false; - private static bool _isRunningAsService = false; /// @@ -132,7 +130,7 @@ namespace MediaBrowser.ServerApplication if (duplicate != null) { _logger.Info("Found a duplicate process. Giving it time to exit."); - + if (!duplicate.WaitForExit(5000)) { _logger.Info("The duplicate process did not exit."); @@ -204,7 +202,7 @@ namespace MediaBrowser.ServerApplication SetErrorMode(ErrorModes.SEM_FAILCRITICALERRORS | ErrorModes.SEM_NOALIGNMENTFAULTEXCEPT | ErrorModes.SEM_NOGPFAULTERRORBOX | ErrorModes.SEM_NOOPENFILEERRORBOX); } - + _app.Run(); } @@ -249,13 +247,6 @@ namespace MediaBrowser.ServerApplication SetErrorMode(ErrorModes.SYSTEM_DEFAULT); } - if (_isRestarting) - { - Process.Start("cmd", "/c net start " + BackgroundService.Name); - - _logger.Info("New service process started"); - } - _app.Dispatcher.Invoke(_app.Shutdown); } @@ -270,6 +261,11 @@ namespace MediaBrowser.ServerApplication { ManagedInstallerClass.InstallHelper(new[] { runningPath }); + using (var process = Process.Start("cmd.exe", "/c sc failure " + BackgroundService.Name + " reset= 0 actions= restart/1000/restart/1000/restart/60000")) + { + process.WaitForExit(); + } + logger.Info("Service installation succeeded"); } catch (Exception ex) @@ -445,15 +441,6 @@ namespace MediaBrowser.ServerApplication _logger.Info("Disposing app host"); _appHost.Dispose(); - _logger.Info("Starting new instance of server"); - RestartInternal(); - - _logger.Info("Shutting down existing instance of server."); - Shutdown(); - } - - private static void RestartInternal() - { if (!_isRunningAsService) { _logger.Info("Starting server application"); @@ -461,8 +448,8 @@ namespace MediaBrowser.ServerApplication } else { - _logger.Info("Starting windows service"); - RestartWindowsService(); + _logger.Info("Calling Enviornment.Exit to tell Windows to restart the server."); + Environment.Exit(1); } } @@ -471,11 +458,6 @@ namespace MediaBrowser.ServerApplication System.Windows.Forms.Application.Restart(); } - private static void RestartWindowsService() - { - _isRestarting = true; - } - private static void ShutdownWindowsApplication() { _app.Dispatcher.Invoke(_app.Shutdown); diff --git a/Nuget/MediaBrowser.Common.Internal.nuspec b/Nuget/MediaBrowser.Common.Internal.nuspec index 92c8f2c05..b7fd2a38f 100644 --- a/Nuget/MediaBrowser.Common.Internal.nuspec +++ b/Nuget/MediaBrowser.Common.Internal.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common.Internal - 3.0.221 + 3.0.222 MediaBrowser.Common.Internal Luke ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains common components shared by Media Browser Theater and Media Browser Server. Not intended for plugin developer consumption. Copyright © Media Browser 2013 - + diff --git a/Nuget/MediaBrowser.Common.nuspec b/Nuget/MediaBrowser.Common.nuspec index 3baf5d96f..f6b3aeef8 100644 --- a/Nuget/MediaBrowser.Common.nuspec +++ b/Nuget/MediaBrowser.Common.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common - 3.0.221 + 3.0.222 MediaBrowser.Common Media Browser Team ebr,Luke,scottisafool diff --git a/Nuget/MediaBrowser.Server.Core.nuspec b/Nuget/MediaBrowser.Server.Core.nuspec index 147850f29..b8227fa04 100644 --- a/Nuget/MediaBrowser.Server.Core.nuspec +++ b/Nuget/MediaBrowser.Server.Core.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Server.Core - 3.0.221 + 3.0.222 Media Browser.Server.Core Media Browser Team ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains core components required to build plugins for Media Browser Server. Copyright © Media Browser 2013 - +