mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-27 15:07:03 +01:00
Make process priorities a configuration option
This commit is contained in:
+1
-1
@@ -4,7 +4,7 @@
|
||||
<Import Project="ControlPanelVersion.props" />
|
||||
<PropertyGroup>
|
||||
<TgsCoreVersion>4.15.6</TgsCoreVersion>
|
||||
<TgsConfigVersion>4.0.0</TgsConfigVersion>
|
||||
<TgsConfigVersion>4.1.0</TgsConfigVersion>
|
||||
<TgsApiVersion>9.3.0</TgsApiVersion>
|
||||
<TgsApiLibraryVersion>9.3.1</TgsApiLibraryVersion>
|
||||
<TgsClientVersion>10.4.1</TgsClientVersion>
|
||||
|
||||
@@ -7,6 +7,7 @@ using System.Threading.Tasks;
|
||||
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
using Tgstation.Server.Api.Models;
|
||||
using Tgstation.Server.Api.Models.Internal;
|
||||
@@ -16,6 +17,7 @@ using Tgstation.Server.Host.Components.Deployment.Remote;
|
||||
using Tgstation.Server.Host.Components.Events;
|
||||
using Tgstation.Server.Host.Components.Repository;
|
||||
using Tgstation.Server.Host.Components.Session;
|
||||
using Tgstation.Server.Host.Configuration;
|
||||
using Tgstation.Server.Host.Database;
|
||||
using Tgstation.Server.Host.Extensions;
|
||||
using Tgstation.Server.Host.IO;
|
||||
@@ -93,6 +95,11 @@ namespace Tgstation.Server.Host.Components.Deployment
|
||||
/// </summary>
|
||||
readonly ILogger<DreamMaker> logger;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="SessionConfiguration"/> for <see cref="DreamMaker"/>.
|
||||
/// </summary>
|
||||
readonly SessionConfiguration sessionConfiguration;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="Instance"/> <see cref="DreamMaker"/> belongs to.
|
||||
/// </summary>
|
||||
@@ -147,6 +154,7 @@ namespace Tgstation.Server.Host.Components.Deployment
|
||||
/// <param name="repositoryManager">The value of <see cref="repositoryManager"/>.</param>
|
||||
/// <param name="remoteDeploymentManagerFactory">The value of <see cref="remoteDeploymentManagerFactory"/>.</param>
|
||||
/// <param name="logger">The value of <see cref="logger"/>.</param>
|
||||
/// <param name="sessionConfigurationOptions">The <see cref="IOptions{TOptions}"/> containing the value of <see cref="sessionConfiguration"/>.</param>
|
||||
/// <param name="metadata">The value of <see cref="metadata"/>.</param>
|
||||
public DreamMaker(
|
||||
IByondManager byond,
|
||||
@@ -160,6 +168,7 @@ namespace Tgstation.Server.Host.Components.Deployment
|
||||
IRepositoryManager repositoryManager,
|
||||
IRemoteDeploymentManagerFactory remoteDeploymentManagerFactory,
|
||||
ILogger<DreamMaker> logger,
|
||||
IOptions<SessionConfiguration> sessionConfigurationOptions,
|
||||
Api.Models.Instance metadata)
|
||||
{
|
||||
this.byond = byond ?? throw new ArgumentNullException(nameof(byond));
|
||||
@@ -173,6 +182,7 @@ namespace Tgstation.Server.Host.Components.Deployment
|
||||
this.repositoryManager = repositoryManager ?? throw new ArgumentNullException(nameof(repositoryManager));
|
||||
this.remoteDeploymentManagerFactory = remoteDeploymentManagerFactory ?? throw new ArgumentNullException(nameof(remoteDeploymentManagerFactory));
|
||||
this.logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
||||
sessionConfiguration = sessionConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(sessionConfigurationOptions));
|
||||
this.metadata = metadata ?? throw new ArgumentNullException(nameof(metadata));
|
||||
|
||||
deploymentLock = new object();
|
||||
@@ -825,6 +835,10 @@ namespace Tgstation.Server.Host.Components.Deployment
|
||||
true,
|
||||
true,
|
||||
true);
|
||||
|
||||
if (sessionConfiguration.LowPriorityDeploymentProcesses)
|
||||
dm.AdjustPriority(false);
|
||||
|
||||
int exitCode;
|
||||
using (cancellationToken.Register(() => dm.Terminate()))
|
||||
exitCode = await dm.Lifetime.ConfigureAwait(false);
|
||||
|
||||
@@ -7,6 +7,7 @@ using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
using Tgstation.Server.Api;
|
||||
using Tgstation.Server.Api.Models;
|
||||
@@ -17,6 +18,7 @@ using Tgstation.Server.Host.Components.Deployment;
|
||||
using Tgstation.Server.Host.Components.Events;
|
||||
using Tgstation.Server.Host.Components.Interop;
|
||||
using Tgstation.Server.Host.Components.Interop.Bridge;
|
||||
using Tgstation.Server.Host.Configuration;
|
||||
using Tgstation.Server.Host.Core;
|
||||
using Tgstation.Server.Host.Extensions;
|
||||
using Tgstation.Server.Host.IO;
|
||||
@@ -99,6 +101,11 @@ namespace Tgstation.Server.Host.Components.Session
|
||||
/// </summary>
|
||||
readonly ILogger<SessionControllerFactory> logger;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="SessionConfiguration"/> for the <see cref="SessionControllerFactory"/>.
|
||||
/// </summary>
|
||||
readonly SessionConfiguration sessionConfiguration;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="Api.Models.Instance"/> for the <see cref="SessionControllerFactory"/>.
|
||||
/// </summary>
|
||||
@@ -170,7 +177,8 @@ namespace Tgstation.Server.Host.Components.Session
|
||||
/// <param name="serverPortProvider">The value of <see cref="serverPortProvider"/>.</param>
|
||||
/// <param name="loggerFactory">The value of <see cref="loggerFactory"/>.</param>
|
||||
/// <param name="logger">The value of <see cref="logger"/>.</param>
|
||||
/// <param name="eventConsumer">The value of <see cref="EventConsumer"/>.</param>
|
||||
/// <param name="sessionConfigurationOptions">The <see cref="IOptions{TOptions}"/> containing the value of <see cref="sessionConfiguration"/>.</param>
|
||||
/// <param name="eventConsumer">The value of <see cref="eventConsumer"/>.</param>
|
||||
public SessionControllerFactory(
|
||||
IProcessExecutor processExecutor,
|
||||
IByondManager byond,
|
||||
@@ -183,9 +191,10 @@ namespace Tgstation.Server.Host.Components.Session
|
||||
IPlatformIdentifier platformIdentifier,
|
||||
IBridgeRegistrar bridgeRegistrar,
|
||||
IServerPortProvider serverPortProvider,
|
||||
EventConsumer eventConsumer,
|
||||
IEventConsumer eventConsumer,
|
||||
ILoggerFactory loggerFactory,
|
||||
ILogger<SessionControllerFactory> logger,
|
||||
IOptions<SessionConfiguration> sessionConfigurationOptions,
|
||||
Api.Models.Instance instance)
|
||||
{
|
||||
this.processExecutor = processExecutor ?? throw new ArgumentNullException(nameof(processExecutor));
|
||||
@@ -193,7 +202,6 @@ namespace Tgstation.Server.Host.Components.Session
|
||||
this.topicClientFactory = topicClientFactory ?? throw new ArgumentNullException(nameof(topicClientFactory));
|
||||
this.cryptographySuite = cryptographySuite ?? throw new ArgumentNullException(nameof(cryptographySuite));
|
||||
this.assemblyInformationProvider = assemblyInformationProvider ?? throw new ArgumentNullException(nameof(assemblyInformationProvider));
|
||||
this.instance = instance ?? throw new ArgumentNullException(nameof(instance));
|
||||
this.ioManager = ioManager ?? throw new ArgumentNullException(nameof(ioManager));
|
||||
this.chat = chat ?? throw new ArgumentNullException(nameof(chat));
|
||||
this.networkPromptReaper = networkPromptReaper ?? throw new ArgumentNullException(nameof(networkPromptReaper));
|
||||
@@ -203,6 +211,8 @@ namespace Tgstation.Server.Host.Components.Session
|
||||
this.eventConsumer = eventConsumer ?? throw new ArgumentNullException(nameof(eventConsumer));
|
||||
this.loggerFactory = loggerFactory ?? throw new ArgumentNullException(nameof(loggerFactory));
|
||||
this.logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
||||
sessionConfiguration = sessionConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(sessionConfigurationOptions));
|
||||
this.instance = instance ?? throw new ArgumentNullException(nameof(instance));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -380,6 +390,14 @@ namespace Tgstation.Server.Host.Components.Session
|
||||
false,
|
||||
apiValidate);
|
||||
|
||||
if (apiValidate)
|
||||
{
|
||||
if (sessionConfiguration.HighPriorityLiveDreamDaemon)
|
||||
process.AdjustPriority(true);
|
||||
}
|
||||
else if (sessionConfiguration.LowPriorityDeploymentProcesses)
|
||||
process.AdjustPriority(false);
|
||||
|
||||
// If this isnt a staging DD (From a Deployment), fire off an event
|
||||
if (!apiValidate)
|
||||
await eventConsumer.HandleEvent(
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Tgstation.Server.Host.Configuration
|
||||
namespace Tgstation.Server.Host.Configuration
|
||||
{
|
||||
/// <summary>
|
||||
/// Configuration options for the web control panel.
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
namespace Tgstation.Server.Host.Configuration
|
||||
{
|
||||
/// <summary>
|
||||
/// Configuration options for the game sessions.
|
||||
/// </summary>
|
||||
sealed class SessionConfiguration
|
||||
{
|
||||
/// <summary>
|
||||
/// The key for the <see cref="Microsoft.Extensions.Configuration.IConfigurationSection"/> the <see cref="SessionConfiguration"/> resides in.
|
||||
/// </summary>
|
||||
public const string Section = "Session";
|
||||
|
||||
/// <summary>
|
||||
/// If the public DreamDaemon instances are set to be above normal priority processes.
|
||||
/// </summary>
|
||||
public bool HighPriorityLiveDreamDaemon { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// If the deployment DreamMaker and DreamDaemon instances are set to be below normal priority processes.
|
||||
/// </summary>
|
||||
public bool LowPriorityDeploymentProcesses { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -120,6 +120,7 @@ namespace Tgstation.Server.Host.Core
|
||||
services.UseStandardConfig<UpdatesConfiguration>(Configuration);
|
||||
services.UseStandardConfig<ControlPanelConfiguration>(Configuration);
|
||||
services.UseStandardConfig<SwarmConfiguration>(Configuration);
|
||||
services.UseStandardConfig<SessionConfiguration>(Configuration);
|
||||
|
||||
// enable options which give us config reloading
|
||||
services.AddOptions();
|
||||
|
||||
@@ -11,6 +11,9 @@ General:
|
||||
InstanceLimit: 10
|
||||
ValidInstancePaths:
|
||||
HostApiDocumentation: false
|
||||
Session:
|
||||
HighPriorityLiveDreamDaemon: false
|
||||
LowPriorityDeploymentProcesses: true
|
||||
FileLogging:
|
||||
Directory:
|
||||
Disable: false
|
||||
|
||||
Reference in New Issue
Block a user