Does the process priority thing for the Watchdog

This commit is contained in:
Jordan Brown
2018-08-18 15:13:57 -04:00
parent 5f44fa77ba
commit dab27eadc5
4 changed files with 20 additions and 1 deletions
@@ -427,5 +427,8 @@ namespace Tgstation.Server.Host.Components.Watchdog
CheckDisposed();
reattachInformation.RebootState = RebootState.Normal;
}
/// <inheritdoc />
public void SetHighPriority() => process.SetHighPriority();
}
}
@@ -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<LaunchResult> CheckLaunch(ISessionController controller, string serverName)
{
var launch = await controller.LaunchResult.ConfigureAwait(false);
@@ -12,5 +12,10 @@ namespace Tgstation.Server.Host.Core
/// The <see cref="Task{TResult}"/> resulting in the exit code of the process
/// </summary>
Task<int> Lifetime { get; }
/// <summary>
/// Set's the owned <see cref="System.Diagnostics.Process.PriorityClass"/> to <see cref="System.Diagnostics.ProcessPriorityClass.AboveNormal"/>
/// </summary>
void SetHighPriority();
}
}
@@ -79,5 +79,14 @@ namespace Tgstation.Server.Host.Core
}
catch (InvalidOperationException) { }
}
public void SetHighPriority()
{
try
{
handle.PriorityClass = System.Diagnostics.ProcessPriorityClass.AboveNormal;
}
catch (InvalidOperationException) { }
}
}
}