From dab27eadc5f868f037e000fb1e80951e5462010d Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Sat, 18 Aug 2018 15:13:57 -0400 Subject: [PATCH] Does the process priority thing for the Watchdog --- .../Components/Watchdog/SessionController.cs | 3 +++ .../Components/Watchdog/Watchdog.cs | 4 +++- src/Tgstation.Server.Host/Core/IProcessBase.cs | 5 +++++ src/Tgstation.Server.Host/Core/Process.cs | 9 +++++++++ 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/Tgstation.Server.Host/Components/Watchdog/SessionController.cs b/src/Tgstation.Server.Host/Components/Watchdog/SessionController.cs index fde13f58c2..6a6448678b 100644 --- a/src/Tgstation.Server.Host/Components/Watchdog/SessionController.cs +++ b/src/Tgstation.Server.Host/Components/Watchdog/SessionController.cs @@ -427,5 +427,8 @@ namespace Tgstation.Server.Host.Components.Watchdog CheckDisposed(); reattachInformation.RebootState = RebootState.Normal; } + + /// + public void SetHighPriority() => process.SetHighPriority(); } } diff --git a/src/Tgstation.Server.Host/Components/Watchdog/Watchdog.cs b/src/Tgstation.Server.Host/Components/Watchdog/Watchdog.cs index 5d35904214..df759f6de9 100644 --- a/src/Tgstation.Server.Host/Components/Watchdog/Watchdog.cs +++ b/src/Tgstation.Server.Host/Components/Watchdog/Watchdog.cs @@ -665,6 +665,7 @@ namespace Tgstation.Server.Host.Components.Watchdog //wait until this boy officially starts so as not to confuse the servers as to who came first var startTime = DateTimeOffset.Now; alphaServer = await alphaServerTask.ConfigureAwait(false); + alphaServer.SetHighPriority(); //extra delay for total ordering var now = DateTimeOffset.Now; @@ -680,7 +681,8 @@ namespace Tgstation.Server.Host.Components.Watchdog bravoServerTask = sessionControllerFactory.Reattach(reattachInfo.Bravo, cancellationToken); bravoServer = await bravoServerTask.ConfigureAwait(false); - + bravoServer.SetHighPriority(); + async Task CheckLaunch(ISessionController controller, string serverName) { var launch = await controller.LaunchResult.ConfigureAwait(false); diff --git a/src/Tgstation.Server.Host/Core/IProcessBase.cs b/src/Tgstation.Server.Host/Core/IProcessBase.cs index b96b93b2ae..cc287208c4 100644 --- a/src/Tgstation.Server.Host/Core/IProcessBase.cs +++ b/src/Tgstation.Server.Host/Core/IProcessBase.cs @@ -12,5 +12,10 @@ namespace Tgstation.Server.Host.Core /// The resulting in the exit code of the process /// Task Lifetime { get; } + + /// + /// Set's the owned to + /// + void SetHighPriority(); } } diff --git a/src/Tgstation.Server.Host/Core/Process.cs b/src/Tgstation.Server.Host/Core/Process.cs index cd869ee83a..15296ebb2f 100644 --- a/src/Tgstation.Server.Host/Core/Process.cs +++ b/src/Tgstation.Server.Host/Core/Process.cs @@ -79,5 +79,14 @@ namespace Tgstation.Server.Host.Core } catch (InvalidOperationException) { } } + + public void SetHighPriority() + { + try + { + handle.PriorityClass = System.Diagnostics.ProcessPriorityClass.AboveNormal; + } + catch (InvalidOperationException) { } + } } }