mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-24 05:27:30 +01:00
Merge branch 'Stuff' into 1858-AppSupport
This commit is contained in:
+5
-5
@@ -3,15 +3,15 @@
|
||||
<!-- Integration tests will ensure they match across the board -->
|
||||
<Import Project="WebpanelVersion.props" />
|
||||
<PropertyGroup>
|
||||
<TgsCoreVersion>6.9.2</TgsCoreVersion>
|
||||
<TgsCoreVersion>6.10.0</TgsCoreVersion>
|
||||
<TgsConfigVersion>5.2.0</TgsConfigVersion>
|
||||
<TgsApiVersion>10.7.0</TgsApiVersion>
|
||||
<TgsApiVersion>10.8.0</TgsApiVersion>
|
||||
<TgsCommonLibraryVersion>7.0.0</TgsCommonLibraryVersion>
|
||||
<TgsApiLibraryVersion>13.7.0</TgsApiLibraryVersion>
|
||||
<TgsClientVersion>16.0.0</TgsClientVersion>
|
||||
<TgsDmapiVersion>7.2.1</TgsDmapiVersion>
|
||||
<TgsInteropVersion>5.9.0</TgsInteropVersion>
|
||||
<TgsHostWatchdogVersion>1.4.1</TgsHostWatchdogVersion>
|
||||
<TgsDmapiVersion>7.3.0</TgsDmapiVersion>
|
||||
<TgsInteropVersion>5.10.0</TgsInteropVersion>
|
||||
<TgsHostWatchdogVersion>1.5.0</TgsHostWatchdogVersion>
|
||||
<TgsContainerScriptVersion>1.2.1</TgsContainerScriptVersion>
|
||||
<TgsMigratorVersion>2.0.0</TgsMigratorVersion>
|
||||
<TgsNugetNetFramework>netstandard2.0</TgsNugetNetFramework>
|
||||
|
||||
@@ -11,7 +11,7 @@ User=tgstation-server
|
||||
Type=notify-reload
|
||||
NotifyAccess=all
|
||||
WorkingDirectory=/opt/tgstation-server
|
||||
ExecStart=/usr/bin/dotnet Tgstation.Server.Host.Console.dll --appsettings-base-path=/etc/tgstation-server --General:SetupWizardMode=Never --Internal:UsingSystemD=true
|
||||
ExecStart=/usr/bin/dotnet Tgstation.Server.Host.Console.dll --appsettings-base-path=/etc/tgstation-server --General:SetupWizardMode=Never
|
||||
TimeoutStartSec=600
|
||||
Restart=always
|
||||
KillMode=process
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
// tgstation-server DMAPI
|
||||
// The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in IETF RFC 2119.
|
||||
|
||||
#define TGS_DMAPI_VERSION "7.2.1"
|
||||
#define TGS_DMAPI_VERSION "7.3.0"
|
||||
|
||||
// All functions and datums outside this document are subject to change with any version and should not be relied on.
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
"5.9.0"
|
||||
"5.10.0"
|
||||
|
||||
@@ -95,6 +95,7 @@
|
||||
#define DMAPI5_TOPIC_PARAMETER_NEW_SERVER_VERSION "newServerVersion"
|
||||
#define DMAPI5_TOPIC_PARAMETER_BROADCAST_MESSAGE "broadcastMessage"
|
||||
|
||||
#define DMAPI5_TOPIC_RESPONSE_CLIENT_COUNT "clientCount"
|
||||
#define DMAPI5_TOPIC_RESPONSE_COMMAND_RESPONSE "commandResponse"
|
||||
#define DMAPI5_TOPIC_RESPONSE_COMMAND_RESPONSE_MESSAGE "commandResponseMessage"
|
||||
#define DMAPI5_TOPIC_RESPONSE_CHAT_RESPONSES "chatResponses"
|
||||
|
||||
@@ -149,7 +149,9 @@
|
||||
if(DMAPI5_TOPIC_COMMAND_HEALTHCHECK)
|
||||
if(event_handler && event_handler.receive_health_checks)
|
||||
event_handler.HandleEvent(TGS_EVENT_HEALTH_CHECK)
|
||||
return TopicResponse()
|
||||
var/list/health_check_response = TopicResponse()
|
||||
health_check_response[DMAPI5_TOPIC_RESPONSE_CLIENT_COUNT] = TGS_CLIENT_COUNT
|
||||
return health_check_response;
|
||||
|
||||
if(DMAPI5_TOPIC_COMMAND_WATCHDOG_REATTACH)
|
||||
detached = FALSE
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
#undef DMAPI5_BRIDGE_COMMAND_EVENT
|
||||
|
||||
#undef DMAPI5_PARAMETER_ACCESS_IDENTIFIER
|
||||
#undef DMAPI5_PARAMETER_CLIENT_COUNT
|
||||
#undef DMAPI5_PARAMETER_CUSTOM_COMMANDS
|
||||
#undef DMAPI5_PARAMETER_TOPIC_PORT
|
||||
|
||||
#undef DMAPI5_CHUNK
|
||||
#undef DMAPI5_CHUNK_PAYLOAD
|
||||
@@ -95,6 +95,7 @@
|
||||
#undef DMAPI5_TOPIC_PARAMETER_NEW_SERVER_VERSION
|
||||
#undef DMAPI5_TOPIC_PARAMETER_BROADCAST_MESSAGE
|
||||
|
||||
#undef DMAPI5_TOPIC_RESPONSE_CLIENT_COUNT
|
||||
#undef DMAPI5_TOPIC_RESPONSE_COMMAND_RESPONSE
|
||||
#undef DMAPI5_TOPIC_RESPONSE_COMMAND_RESPONSE_MESSAGE
|
||||
#undef DMAPI5_TOPIC_RESPONSE_CHAT_RESPONSES
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
namespace Tgstation.Server.Api.Models.Internal
|
||||
using System;
|
||||
|
||||
namespace Tgstation.Server.Api.Models.Internal
|
||||
{
|
||||
/// <summary>
|
||||
/// Base class for DreamDaemon API models.
|
||||
@@ -11,6 +13,18 @@
|
||||
[ResponseOptions]
|
||||
public long? SessionId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// When the current server execution was started.
|
||||
/// </summary>
|
||||
[ResponseOptions]
|
||||
public DateTimeOffset? LaunchTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The last known count of connected players. Requires <see cref="DreamDaemonLaunchParameters.HealthCheckSeconds"/> to not be 0 and a game server interop version >= 5.10.0 to populate.
|
||||
/// </summary>
|
||||
[ResponseOptions]
|
||||
public int? ClientCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// If the server is undergoing a soft reset. This may be automatically set by changes to other fields.
|
||||
/// </summary>
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Microsoft.Extensions.Hosting.Systemd;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
using Tgstation.Server.Common;
|
||||
@@ -44,6 +46,11 @@ namespace Tgstation.Server.Host.Console
|
||||
var trace = arguments.Remove("--trace-host-watchdog");
|
||||
var debug = arguments.Remove("--debug-host-watchdog");
|
||||
|
||||
const string SystemDArg = "--Internal:UsingSystemD=true";
|
||||
if (!arguments.Any(arg => arg.Equals(SystemDArg, StringComparison.OrdinalIgnoreCase))
|
||||
&& SystemdHelpers.IsSystemdService())
|
||||
arguments.Add(SystemDArg);
|
||||
|
||||
using var loggerFactory = LoggerFactory.Create(builder =>
|
||||
{
|
||||
if (trace)
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<!-- Usage: Identifying if we're running under SystemD -->
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="8.0.0" />
|
||||
<!-- Usage: Console logging plugin -->
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -36,5 +36,10 @@ namespace Tgstation.Server.Host.Components.Interop.Topic
|
||||
|
||||
/// <inheritdoc />
|
||||
public IReadOnlyCollection<uint>? MissingChunks { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The number of connected clients to the game. Added in Interop 5.10.0.
|
||||
/// </summary>
|
||||
public int? ClientCount { get; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,6 +124,9 @@ namespace Tgstation.Server.Host.Components.Session
|
||||
/// <inheritdoc />
|
||||
public long? MemoryUsage => process.MemoryUsage;
|
||||
|
||||
/// <inheritdoc />
|
||||
public DateTimeOffset? LaunchTime => process.LaunchTime;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="Byond.TopicSender.ITopicClient"/> for the <see cref="SessionController"/>.
|
||||
/// </summary>
|
||||
|
||||
@@ -19,6 +19,16 @@ namespace Tgstation.Server.Host.Components.Watchdog
|
||||
/// </summary>
|
||||
long? SessionId { get; }
|
||||
|
||||
/// <summary>
|
||||
/// When the current server executions was started.
|
||||
/// </summary>
|
||||
DateTimeOffset? LaunchTime { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Last known client count queried from the DMAPI. Requires health checks to be enabled to populate.
|
||||
/// </summary>
|
||||
int? ClientCount { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The current <see cref="WatchdogStatus"/>.
|
||||
/// </summary>
|
||||
|
||||
@@ -38,6 +38,12 @@ namespace Tgstation.Server.Host.Components.Watchdog
|
||||
/// <inheritdoc />
|
||||
public long? SessionId => GetActiveController()?.ReattachInformation.Id;
|
||||
|
||||
/// <inheritdoc />
|
||||
public int? ClientCount { get; private set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public DateTimeOffset? LaunchTime => GetActiveController()?.LaunchTime;
|
||||
|
||||
/// <inheritdoc />
|
||||
public WatchdogStatus Status
|
||||
{
|
||||
@@ -567,6 +573,7 @@ namespace Tgstation.Server.Host.Components.Watchdog
|
||||
// since neither server is running, this is safe to do
|
||||
LastLaunchParameters = ActiveLaunchParameters;
|
||||
healthChecksMissed = 0;
|
||||
ClientCount = null;
|
||||
|
||||
try
|
||||
{
|
||||
@@ -664,6 +671,7 @@ namespace Tgstation.Server.Host.Components.Watchdog
|
||||
// we lost the server, just restart entirely
|
||||
// DCT: Operation must always run
|
||||
await DisposeAndNullControllers(CancellationToken.None);
|
||||
ClientCount = null;
|
||||
const string FailReattachMessage = "Unable to properly reattach to server! Restarting watchdog...";
|
||||
Logger.LogWarning(FailReattachMessage);
|
||||
|
||||
@@ -1180,7 +1188,10 @@ namespace Tgstation.Server.Host.Components.Watchdog
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
healthChecksMissed = 0;
|
||||
ClientCount = response.ClientCount;
|
||||
}
|
||||
|
||||
return MonitorAction.Continue;
|
||||
}
|
||||
|
||||
@@ -366,6 +366,8 @@ namespace Tgstation.Server.Host.Controllers
|
||||
firstIteration = false;
|
||||
result.Status = dd.Status;
|
||||
result.SessionId = dd.SessionId;
|
||||
result.LaunchTime = dd.LaunchTime;
|
||||
result.ClientCount = dd.ClientCount;
|
||||
}
|
||||
while (result.Status == WatchdogStatus.Online && !result.SessionId.HasValue); // this is the one invalid combo, it's not that racy
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Threading;
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Tgstation.Server.Host.System
|
||||
@@ -8,6 +9,11 @@ namespace Tgstation.Server.Host.System
|
||||
/// </summary>
|
||||
public interface IProcessBase
|
||||
{
|
||||
/// <summary>
|
||||
/// When the process was started.
|
||||
/// </summary>
|
||||
DateTimeOffset? LaunchTime { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="Task{TResult}"/> resulting in the exit code of the process or <see langword="null"/> if the process was detached.
|
||||
/// </summary>
|
||||
|
||||
@@ -16,6 +16,23 @@ namespace Tgstation.Server.Host.System
|
||||
/// <inheritdoc />
|
||||
public int Id { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public DateTimeOffset? LaunchTime
|
||||
{
|
||||
get
|
||||
{
|
||||
try
|
||||
{
|
||||
return handle.StartTime;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogWarning(ex, "Failed to get PID {pid}'s memory usage!", Id);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task Startup { get; }
|
||||
|
||||
|
||||
@@ -682,6 +682,7 @@ namespace Tgstation.Server.Tests.Live.Instance
|
||||
Assert.AreEqual(WatchdogStatus.Offline, daemonStatus.Status.Value);
|
||||
Assert.IsNotNull(daemonStatus.ActiveCompileJob);
|
||||
Assert.IsFalse(daemonStatus.SessionId.HasValue);
|
||||
Assert.IsFalse(daemonStatus.LaunchTime.HasValue);
|
||||
Assert.IsNull(daemonStatus.StagedCompileJob);
|
||||
Assert.AreEqual(DMApiConstants.InteropVersion, daemonStatus.ActiveCompileJob.DMApiVersion);
|
||||
Assert.AreEqual(DreamDaemonSecurity.Trusted, daemonStatus.ActiveCompileJob.MinimumSecurityLevel);
|
||||
@@ -730,6 +731,7 @@ namespace Tgstation.Server.Tests.Live.Instance
|
||||
daemonStatus = await instanceClient.DreamDaemon.Read(cancellationToken);
|
||||
Assert.AreEqual(WatchdogStatus.Offline, daemonStatus.Status.Value);
|
||||
Assert.IsFalse(daemonStatus.SessionId.HasValue);
|
||||
Assert.IsFalse(daemonStatus.LaunchTime.HasValue);
|
||||
await ExpectGameDirectoryCount(1, cancellationToken);
|
||||
|
||||
await CheckDMApiFail(daemonStatus.ActiveCompileJob, cancellationToken, false);
|
||||
@@ -741,12 +743,18 @@ namespace Tgstation.Server.Tests.Live.Instance
|
||||
}, cancellationToken);
|
||||
Assert.AreEqual(string.Empty, daemonStatus.AdditionalParameters);
|
||||
Assert.IsFalse(daemonStatus.SessionId.HasValue);
|
||||
Assert.IsFalse(daemonStatus.LaunchTime.HasValue);
|
||||
}
|
||||
|
||||
long? sessionIdTracker;
|
||||
void ValidateSessionId(DreamDaemonResponse daemonStatus, bool? knownIncrease)
|
||||
{
|
||||
Assert.IsTrue(daemonStatus.SessionId.HasValue, $"Expected a session ID in the DreamDaemonResponse");
|
||||
Assert.IsTrue(daemonStatus.LaunchTime.HasValue);
|
||||
Assert.IsTrue(daemonStatus.LaunchTime.Value >= DateTimeOffset.UtcNow.AddHours(-1));
|
||||
|
||||
if (daemonStatus.ClientCount.HasValue)
|
||||
Assert.AreEqual(0, daemonStatus.ClientCount.Value);
|
||||
|
||||
if (sessionIdTracker.HasValue)
|
||||
if (knownIncrease.HasValue)
|
||||
@@ -856,6 +864,8 @@ namespace Tgstation.Server.Tests.Live.Instance
|
||||
// Ensure it's responding to health checks
|
||||
await Task.WhenAny(Task.Delay(7000, cancellationToken), ourProcessHandler.Lifetime);
|
||||
Assert.IsFalse(ddProc.HasExited);
|
||||
var daemonStatus = await instanceClient.DreamDaemon.Read(cancellationToken);
|
||||
Assert.AreEqual(0, daemonStatus.ClientCount);
|
||||
|
||||
// check DD agrees
|
||||
var topicRequestResult = await SendTestTopic(
|
||||
|
||||
Reference in New Issue
Block a user