mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-30 16:39:21 +01:00
Merge pull request #999 from tgstation/997-KeepThoseCommands
Send Server Commands on Reattach
This commit is contained in:
@@ -14,10 +14,5 @@ coverage:
|
||||
default:
|
||||
target: 100
|
||||
only_pulls: true
|
||||
changes:
|
||||
default:
|
||||
if_no_uploads: failure
|
||||
if_ci_failed: failure
|
||||
only_pulls: yes
|
||||
comment:
|
||||
layout: "header, diff, changes"
|
||||
|
||||
+4
-4
@@ -2,10 +2,10 @@
|
||||
<PropertyGroup>
|
||||
<!-- This is the authorative version list -->
|
||||
<!-- Integration tests will ensure they match across the board -->
|
||||
<TgsCoreVersion>4.2.2</TgsCoreVersion>
|
||||
<TgsApiVersion>6.3.0</TgsApiVersion>
|
||||
<TgsClientVersion>6.2.0</TgsClientVersion>
|
||||
<TgsDmapiVersion>5.1.1</TgsDmapiVersion>
|
||||
<TgsCoreVersion>4.2.3</TgsCoreVersion>
|
||||
<TgsApiVersion>6.4.0</TgsApiVersion>
|
||||
<TgsClientVersion>6.3.0</TgsClientVersion>
|
||||
<TgsDmapiVersion>5.2.0</TgsDmapiVersion>
|
||||
<TgsControlPanelVersion>0.4.0</TgsControlPanelVersion>
|
||||
<TgsHostWatchdogVersion>1.1.0</TgsHostWatchdogVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
//tgstation-server DMAPI
|
||||
|
||||
#define TGS_DMAPI_VERSION "5.1.1"
|
||||
#define TGS_DMAPI_VERSION "5.2.0"
|
||||
|
||||
//All functions and datums outside this document are subject to change with any version and should not be relied on
|
||||
|
||||
|
||||
@@ -12,13 +12,14 @@
|
||||
#define DMAPI5_BRIDGE_COMMAND_CHAT_SEND 5
|
||||
|
||||
#define DMAPI5_PARAMETER_ACCESS_IDENTIFIER "accessIdentifier"
|
||||
#define DMAPI5_PARAMETER_CUSTOM_COMMANDS "customCommands"
|
||||
|
||||
#define DMAPI5_RESPONSE_ERROR_MESSAGE "errorMessage"
|
||||
|
||||
#define DMAPI5_BRIDGE_PARAMETER_COMMAND_TYPE "commandType"
|
||||
#define DMAPI5_BRIDGE_PARAMETER_CURRENT_PORT "currentPort"
|
||||
#define DMAPI5_BRIDGE_PARAMETER_VERSION "version"
|
||||
#define DMAPI5_BRIDGE_PARAMETER_CHAT_MESSAGE "chatMessage"
|
||||
#define DMAPI5_BRIDGE_PARAMETER_CUSTOM_COMMANDS "customCommands"
|
||||
#define DMAPI5_BRIDGE_PARAMETER_MINIMUM_SECURITY_LEVEL "minimumSecurityLevel"
|
||||
|
||||
#define DMAPI5_BRIDGE_RESPONSE_NEW_PORT "newPort"
|
||||
|
||||
+19
-9
@@ -16,7 +16,7 @@
|
||||
var/list/chat_channels
|
||||
|
||||
/datum/tgs_api/v5/ApiVersion()
|
||||
return new /datum/tgs_version("5.1.1")
|
||||
return new /datum/tgs_version("5.2.0")
|
||||
|
||||
/datum/tgs_api/v5/OnWorldNew(minimum_required_security_level)
|
||||
server_port = world.params[DMAPI5_PARAM_SERVER_PORT]
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
var/datum/tgs_version/api_version = ApiVersion()
|
||||
version = null
|
||||
var/list/bridge_response = Bridge(DMAPI5_BRIDGE_COMMAND_STARTUP, list(DMAPI5_BRIDGE_PARAMETER_MINIMUM_SECURITY_LEVEL = minimum_required_security_level, DMAPI5_BRIDGE_PARAMETER_VERSION = api_version.raw_parameter, DMAPI5_BRIDGE_PARAMETER_CUSTOM_COMMANDS = ListCustomCommands()))
|
||||
var/list/bridge_response = Bridge(DMAPI5_BRIDGE_COMMAND_STARTUP, list(DMAPI5_BRIDGE_PARAMETER_MINIMUM_SECURITY_LEVEL = minimum_required_security_level, DMAPI5_BRIDGE_PARAMETER_VERSION = api_version.raw_parameter, DMAPI5_PARAMETER_CUSTOM_COMMANDS = ListCustomCommands()))
|
||||
if(!istype(bridge_response))
|
||||
TGS_ERROR_LOG("Failed initial bridge request!")
|
||||
return FALSE
|
||||
@@ -201,17 +201,27 @@
|
||||
if(DMAPI5_TOPIC_COMMAND_HEARTBEAT)
|
||||
return TopicResponse()
|
||||
if(DMAPI5_TOPIC_COMMAND_WATCHDOG_REATTACH)
|
||||
var/new_port = topic_parameters[DMAPI5_TOPIC_PARAMETER_NEW_PORT]
|
||||
var/error_message = null
|
||||
if (new_port != null)
|
||||
if (!isnum(new_port) || !(new_port > 0))
|
||||
error_message = "Invalid [DMAPI5_TOPIC_PARAMETER_NEW_PORT]]"
|
||||
else
|
||||
server_port = new_port
|
||||
|
||||
var/new_version_string = topic_parameters[DMAPI5_TOPIC_PARAMETER_NEW_SERVER_VERSION]
|
||||
if (!istext(new_version_string))
|
||||
return TopicResponse("Invalid or missing [DMAPI5_TOPIC_PARAMETER_NEW_SERVER_VERSION]]")
|
||||
if(error_message != null)
|
||||
error_message += ", "
|
||||
error_message += "Invalid or missing [DMAPI5_TOPIC_PARAMETER_NEW_SERVER_VERSION]]"
|
||||
else
|
||||
var/datum/tgs_version/new_version = new(new_version_string)
|
||||
if (event_handler)
|
||||
event_handler.HandleEvent(TGS_EVENT_WATCHDOG_REATTACH, new_version)
|
||||
|
||||
var/datum/tgs_version/new_version = new(new_version_string)
|
||||
if (event_handler)
|
||||
event_handler.HandleEvent(TGS_EVENT_WATCHDOG_REATTACH, new_version)
|
||||
version = new_version
|
||||
|
||||
version = new_version
|
||||
|
||||
return TopicResponse()
|
||||
return json_encode(list(DMAPI5_RESPONSE_ERROR_MESSAGE = error_message, DMAPI5_PARAMETER_CUSTOM_COMMANDS = ListCustomCommands()))
|
||||
|
||||
return TopicResponse("Unknown command: [command]")
|
||||
|
||||
|
||||
@@ -12,13 +12,14 @@
|
||||
#undef DMAPI5_BRIDGE_COMMAND_CHAT_SEND
|
||||
|
||||
#undef DMAPI5_PARAMETER_ACCESS_IDENTIFIER
|
||||
#undef DMAPI5_PARAMETER_CUSTOM_COMMANDS
|
||||
|
||||
#undef DMAPI5_RESPONSE_ERROR_MESSAGE
|
||||
|
||||
#undef DMAPI5_BRIDGE_PARAMETER_COMMAND_TYPE
|
||||
#undef DMAPI5_BRIDGE_PARAMETER_CURRENT_PORT
|
||||
#undef DMAPI5_BRIDGE_PARAMETER_VERSION
|
||||
#undef DMAPI5_BRIDGE_PARAMETER_CHAT_MESSAGE
|
||||
#undef DMAPI5_BRIDGE_PARAMETER_CUSTOM_COMMANDS
|
||||
#undef DMAPI5_BRIDGE_PARAMETER_MINIMUM_SECURITY_LEVEL
|
||||
|
||||
#undef DMAPI5_BRIDGE_RESPONSE_NEW_PORT
|
||||
|
||||
@@ -16,5 +16,10 @@ namespace Tgstation.Server.Api.Models
|
||||
/// The <see cref="Api"/> version of the host
|
||||
/// </summary>
|
||||
public Version ApiVersion { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The DMAPI version of the host.
|
||||
/// </summary>
|
||||
public Version DMApiVersion { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,13 +29,17 @@ namespace Tgstation.Server.Host.Components.Chat
|
||||
public IEnumerable<CustomCommand> CustomCommands
|
||||
{
|
||||
get => customCommands;
|
||||
set => customCommands = (value ?? throw new InvalidOperationException("value cannot be null!"))
|
||||
set
|
||||
{
|
||||
customCommands = (value ?? throw new InvalidOperationException("value cannot be null!"))
|
||||
.Select(customCommand =>
|
||||
{
|
||||
customCommand.SetHandler(customCommandHandler);
|
||||
return customCommand;
|
||||
})
|
||||
.ToList();
|
||||
logger.LogTrace("Custom commands set.");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Tgstation.Server.Host.Components.Interop;
|
||||
using Tgstation.Server.Host.Components.Interop.Bridge;
|
||||
|
||||
namespace Tgstation.Server.Host.Components
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Tgstation.Server.Host.Components.Interop;
|
||||
using Tgstation.Server.Host.Components.Interop.Bridge;
|
||||
using Tgstation.Server.Host.Models;
|
||||
|
||||
namespace Tgstation.Server.Host.Components
|
||||
|
||||
@@ -7,7 +7,7 @@ using Tgstation.Server.Host.Components.Byond;
|
||||
using Tgstation.Server.Host.Components.Chat;
|
||||
using Tgstation.Server.Host.Components.Chat.Commands;
|
||||
using Tgstation.Server.Host.Components.Deployment;
|
||||
using Tgstation.Server.Host.Components.Interop;
|
||||
using Tgstation.Server.Host.Components.Interop.Bridge;
|
||||
using Tgstation.Server.Host.Components.Repository;
|
||||
using Tgstation.Server.Host.Components.Session;
|
||||
using Tgstation.Server.Host.Components.Watchdog;
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
using System;
|
||||
|
||||
namespace Tgstation.Server.Host.Components.Interop
|
||||
namespace Tgstation.Server.Host.Components.Interop.Bridge
|
||||
{
|
||||
/// <inheritdoc />
|
||||
sealed class BridgeRegistration : IBridgeRegistration
|
||||
+1
-2
@@ -1,8 +1,7 @@
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Tgstation.Server.Host.Components.Interop.Bridge;
|
||||
|
||||
namespace Tgstation.Server.Host.Components.Interop
|
||||
namespace Tgstation.Server.Host.Components.Interop.Bridge
|
||||
{
|
||||
/// <summary>
|
||||
/// Handler for <see cref="BridgeParameters"/>.
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Tgstation.Server.Host.Components.Interop
|
||||
namespace Tgstation.Server.Host.Components.Interop.Bridge
|
||||
{
|
||||
/// <inheritdoc />
|
||||
interface IBridgeHandler : IBridgeDispatcher
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
namespace Tgstation.Server.Host.Components.Interop
|
||||
namespace Tgstation.Server.Host.Components.Interop.Bridge
|
||||
{
|
||||
/// <summary>
|
||||
/// Registers <see cref="IBridgeHandler"/>s.
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
using System;
|
||||
|
||||
namespace Tgstation.Server.Host.Components.Interop
|
||||
namespace Tgstation.Server.Host.Components.Interop.Bridge
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a registration of an interop session.
|
||||
@@ -33,7 +33,7 @@ namespace Tgstation.Server.Host.Components.Interop
|
||||
/// <summary>
|
||||
/// The DMAPI <see cref="Version"/> being used.
|
||||
/// </summary>
|
||||
public static readonly Version Version = new Version(5, 1, 1);
|
||||
public static readonly Version Version = new Version(5, 2, 0);
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="JsonSerializerSettings"/> for use when communicating with the DMAPI.
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
namespace Tgstation.Server.Host.Components.Interop.Topic
|
||||
using System;
|
||||
|
||||
namespace Tgstation.Server.Host.Components.Interop.Topic
|
||||
{
|
||||
/// <summary>
|
||||
/// The type of topic command being sent.
|
||||
@@ -38,6 +40,7 @@
|
||||
/// <summary>
|
||||
/// The server's port was possibly changed.
|
||||
/// </summary>
|
||||
[Obsolete("Deprecated", true)]
|
||||
ServerPortUpdate,
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -82,9 +82,8 @@ namespace Tgstation.Server.Host.Components.Interop.Topic
|
||||
/// Initializes a new instance of the <see cref="TopicParameters"/> <see langword="class"/>.
|
||||
/// </summary>
|
||||
/// <param name="newPort">The value of <see cref="NewPort"/>.</param>
|
||||
/// <param name="forServer">If this is for a <see cref="TopicCommandType.ServerPortUpdate"/>.</param>
|
||||
public TopicParameters(ushort newPort, bool forServer)
|
||||
: this(forServer ? TopicCommandType.ServerPortUpdate : TopicCommandType.ChangePort)
|
||||
public TopicParameters(ushort newPort)
|
||||
: this(TopicCommandType.ChangePort)
|
||||
{
|
||||
NewPort = newPort;
|
||||
}
|
||||
@@ -123,10 +122,12 @@ namespace Tgstation.Server.Host.Components.Interop.Topic
|
||||
/// Initializes a new instance of the <see cref="TopicParameters"/> <see langword="class"/>.
|
||||
/// </summary>
|
||||
/// <param name="newServerVersion">The value of <see cref="NewServerVersion"/>.</param>
|
||||
public TopicParameters(Version newServerVersion)
|
||||
/// <param name="serverPort">TGS's new API port.</param>
|
||||
public TopicParameters(Version newServerVersion, ushort serverPort)
|
||||
: this(TopicCommandType.ServerRestarted)
|
||||
{
|
||||
NewServerVersion = newServerVersion ?? throw new ArgumentNullException(nameof(newServerVersion));
|
||||
NewPort = serverPort;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using Tgstation.Server.Host.Components.Chat.Commands;
|
||||
|
||||
namespace Tgstation.Server.Host.Components.Interop.Topic
|
||||
{
|
||||
@@ -16,5 +17,10 @@ namespace Tgstation.Server.Host.Components.Interop.Topic
|
||||
/// The <see cref="ChatMessage"/>s to send as the result of a <see cref="TopicCommandType.EventNotification"/> request, if any.
|
||||
/// </summary>
|
||||
public ICollection<ChatMessage> ChatResponses { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The DMAPI <see cref="CustomCommand"/>s for <see cref="TopicCommandType.ServerRestarted"/> requests.
|
||||
/// </summary>
|
||||
public ICollection<CustomCommand> CustomCommands { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ using System.Linq;
|
||||
using System.Net;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Tgstation.Server.Api;
|
||||
using Tgstation.Server.Api.Models;
|
||||
using Tgstation.Server.Host.Components.Byond;
|
||||
using Tgstation.Server.Host.Components.Chat;
|
||||
@@ -194,6 +195,7 @@ namespace Tgstation.Server.Host.Components.Session
|
||||
/// <param name="bridgeRegistrar">The <see cref="IBridgeRegistrar"/> used to populate <see cref="bridgeRegistration"/>.</param>
|
||||
/// <param name="chat">The value of <see cref="chat"/></param>
|
||||
/// <param name="chatTrackingContext">The value of <see cref="chatTrackingContext"/></param>
|
||||
/// <param name="assemblyInformationProvider">The <see cref="IAssemblyInformationProvider"/> for the <see cref="SessionController"/>.</param>
|
||||
/// <param name="logger">The value of <see cref="logger"/></param>
|
||||
/// <param name="startupTimeout">The optional time to wait before failing the <see cref="LaunchResult"/></param>
|
||||
/// <param name="reattached">If this is a reattached session.</param>
|
||||
@@ -205,6 +207,7 @@ namespace Tgstation.Server.Host.Components.Session
|
||||
IChatTrackingContext chatTrackingContext,
|
||||
IBridgeRegistrar bridgeRegistrar,
|
||||
IChatManager chat,
|
||||
IAssemblyInformationProvider assemblyInformationProvider,
|
||||
ILogger<SessionController> logger,
|
||||
uint? startupTimeout,
|
||||
bool reattached)
|
||||
@@ -231,55 +234,21 @@ namespace Tgstation.Server.Host.Components.Session
|
||||
synchronizationLock = new object();
|
||||
|
||||
CancellationTokenSource cts = null;
|
||||
Task lifetimeContinuation = null;
|
||||
lifetimeContinuation = process.Lifetime.ContinueWith(
|
||||
_ = process.Lifetime.ContinueWith(
|
||||
x =>
|
||||
{
|
||||
lock (lifetimeContinuation)
|
||||
cts?.Cancel();
|
||||
cts?.Cancel();
|
||||
chatTrackingContext.Active = false;
|
||||
},
|
||||
TaskScheduler.Current);
|
||||
|
||||
async Task<LaunchResult> GetLaunchResult()
|
||||
{
|
||||
var startTime = DateTimeOffset.Now;
|
||||
Task toAwait = process.Startup;
|
||||
|
||||
if (startupTimeout.HasValue)
|
||||
toAwait = Task.WhenAny(process.Startup, Task.Delay(startTime.AddSeconds(startupTimeout.Value) - startTime));
|
||||
|
||||
await toAwait.ConfigureAwait(false);
|
||||
|
||||
var result = new LaunchResult
|
||||
{
|
||||
ExitCode = process.Lifetime.IsCompleted ? (int?)await process.Lifetime.ConfigureAwait(false) : null,
|
||||
StartupTime = process.Startup.IsCompleted ? (TimeSpan?)(DateTimeOffset.Now - startTime) : null
|
||||
};
|
||||
|
||||
logger.LogTrace("Launch result: {0}", result);
|
||||
|
||||
if (!result.ExitCode.HasValue && reattached)
|
||||
using (cts = new CancellationTokenSource())
|
||||
try
|
||||
{
|
||||
await SendCommand(
|
||||
new TopicParameters(
|
||||
reattachInformation.RuntimeInformation.ServerPort,
|
||||
true),
|
||||
cts.Token)
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
finally
|
||||
{
|
||||
lock (lifetimeContinuation)
|
||||
cts = null;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
LaunchResult = GetLaunchResult();
|
||||
LaunchResult = GetLaunchResult(
|
||||
assemblyInformationProvider,
|
||||
#pragma warning disable CA2000 // Dispose objects before losing scope
|
||||
cts = new CancellationTokenSource(),
|
||||
#pragma warning restore CA2000 // Dispose objects before losing scope
|
||||
startupTimeout,
|
||||
reattached);
|
||||
|
||||
logger.LogDebug("Created session controller. Primary: {0}, CommsKey: {1}, Port: {2}", IsPrimary, reattachInformation.AccessIdentifier, Port);
|
||||
}
|
||||
@@ -336,6 +305,51 @@ namespace Tgstation.Server.Host.Components.Session
|
||||
}
|
||||
}
|
||||
|
||||
async Task<LaunchResult> GetLaunchResult(
|
||||
IAssemblyInformationProvider assemblyInformationProvider,
|
||||
CancellationTokenSource cancellationTokenSource,
|
||||
uint? startupTimeout,
|
||||
bool reattached)
|
||||
{
|
||||
using (cancellationTokenSource)
|
||||
{
|
||||
var startTime = DateTimeOffset.Now;
|
||||
Task toAwait = process.Startup;
|
||||
|
||||
if (startupTimeout.HasValue)
|
||||
toAwait = Task.WhenAny(process.Startup, Task.Delay(startTime.AddSeconds(startupTimeout.Value) - startTime));
|
||||
|
||||
await toAwait.ConfigureAwait(false);
|
||||
|
||||
var result = new LaunchResult
|
||||
{
|
||||
ExitCode = process.Lifetime.IsCompleted ? (int?)await process.Lifetime.ConfigureAwait(false) : null,
|
||||
StartupTime = process.Startup.IsCompleted ? (TimeSpan?)(DateTimeOffset.Now - startTime) : null
|
||||
};
|
||||
|
||||
logger.LogTrace("Launch result: {0}", result);
|
||||
|
||||
if (!result.ExitCode.HasValue && reattached)
|
||||
{
|
||||
var reattachResponse = await SendCommand(
|
||||
new TopicParameters(
|
||||
assemblyInformationProvider.Version,
|
||||
reattachInformation.RuntimeInformation.ServerPort),
|
||||
cancellationTokenSource.Token)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
if (reattachResponse.InteropResponse?.CustomCommands != null)
|
||||
chatTrackingContext.CustomCommands = reattachResponse.InteropResponse.CustomCommands;
|
||||
else if (reattachResponse.InteropResponse != null)
|
||||
logger.LogWarning(
|
||||
"DMAPI v{0} isn't returning the TGS custom commands list. Functionality added in v5.2.0.",
|
||||
Dmb.CompileJob.DMApiVersion.Semver());
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<BridgeResponse> ProcessBridgeRequest(BridgeParameters parameters, CancellationToken cancellationToken)
|
||||
{
|
||||
@@ -454,7 +468,7 @@ namespace Tgstation.Server.Host.Components.Session
|
||||
response.RuntimeInformation = reattachInformation.RuntimeInformation;
|
||||
|
||||
// Load custom commands
|
||||
chatTrackingContext.CustomCommands = parameters.CustomCommands.ToList();
|
||||
chatTrackingContext.CustomCommands = parameters.CustomCommands;
|
||||
break;
|
||||
case BridgeCommandType.Reboot:
|
||||
if (ClosePortOnReboot)
|
||||
@@ -585,7 +599,7 @@ namespace Tgstation.Server.Host.Components.Session
|
||||
async Task<bool> ImmediateTopicPortChange()
|
||||
{
|
||||
var commandResult = await SendCommand(
|
||||
new TopicParameters(port, false),
|
||||
new TopicParameters(port),
|
||||
cancellationToken)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
|
||||
@@ -289,6 +289,7 @@ namespace Tgstation.Server.Host.Components.Session
|
||||
chatTrackingContext,
|
||||
bridgeRegistrar,
|
||||
chat,
|
||||
assemblyInformationProvider,
|
||||
loggerFactory.CreateLogger<SessionController>(),
|
||||
launchParameters.StartupTimeout,
|
||||
false);
|
||||
@@ -353,6 +354,7 @@ namespace Tgstation.Server.Host.Components.Session
|
||||
chatTrackingContext,
|
||||
bridgeRegistrar,
|
||||
chat,
|
||||
assemblyInformationProvider,
|
||||
loggerFactory.CreateLogger<SessionController>(),
|
||||
null,
|
||||
true);
|
||||
|
||||
@@ -11,7 +11,6 @@ using Tgstation.Server.Host.Components.Session;
|
||||
using Tgstation.Server.Host.Core;
|
||||
using Tgstation.Server.Host.Database;
|
||||
using Tgstation.Server.Host.Jobs;
|
||||
using Tgstation.Server.Host.System;
|
||||
|
||||
namespace Tgstation.Server.Host.Components.Watchdog
|
||||
{
|
||||
@@ -50,7 +49,6 @@ namespace Tgstation.Server.Host.Components.Watchdog
|
||||
/// <param name="jobManager">The <see cref="IJobManager"/> for the <see cref="WatchdogBase"/>.</param>
|
||||
/// <param name="serverControl">The <see cref="IServerControl"/> for the <see cref="WatchdogBase"/>.</param>
|
||||
/// <param name="asyncDelayer">The <see cref="IAsyncDelayer"/> for the <see cref="WatchdogBase"/>.</param>
|
||||
/// <param name="assemblyInformationProvider">The <see cref="IAssemblyInformationProvider"/> for the <see cref="WatchdogBase"/>.</param>
|
||||
/// <param name="logger">The <see cref="ILogger"/> for the <see cref="WatchdogBase"/>.</param>
|
||||
/// <param name="initialLaunchParameters">The <see cref="DreamDaemonLaunchParameters"/> for the <see cref="WatchdogBase"/>.</param>
|
||||
/// <param name="instance">The <see cref="Api.Models.Instance"/> for the <see cref="WatchdogBase"/>.</param>
|
||||
@@ -64,7 +62,6 @@ namespace Tgstation.Server.Host.Components.Watchdog
|
||||
IJobManager jobManager,
|
||||
IServerControl serverControl,
|
||||
IAsyncDelayer asyncDelayer,
|
||||
IAssemblyInformationProvider assemblyInformationProvider,
|
||||
ILogger<BasicWatchdog> logger,
|
||||
DreamDaemonLaunchParameters initialLaunchParameters,
|
||||
Api.Models.Instance instance,
|
||||
@@ -78,7 +75,6 @@ namespace Tgstation.Server.Host.Components.Watchdog
|
||||
jobManager,
|
||||
serverControl,
|
||||
asyncDelayer,
|
||||
assemblyInformationProvider,
|
||||
logger,
|
||||
initialLaunchParameters,
|
||||
instance,
|
||||
|
||||
@@ -12,7 +12,6 @@ using Tgstation.Server.Host.Components.Session;
|
||||
using Tgstation.Server.Host.Core;
|
||||
using Tgstation.Server.Host.Database;
|
||||
using Tgstation.Server.Host.Jobs;
|
||||
using Tgstation.Server.Host.System;
|
||||
|
||||
namespace Tgstation.Server.Host.Components.Watchdog
|
||||
{
|
||||
@@ -61,7 +60,6 @@ namespace Tgstation.Server.Host.Components.Watchdog
|
||||
/// <param name="jobManager">The <see cref="IJobManager"/> for the <see cref="WatchdogBase"/>.</param>
|
||||
/// <param name="serverControl">The <see cref="IServerControl"/> for the <see cref="WatchdogBase"/>.</param>
|
||||
/// <param name="asyncDelayer">The <see cref="IAsyncDelayer"/> for the <see cref="WatchdogBase"/>.</param>
|
||||
/// <param name="assemblyInformationProvider">The <see cref="IAssemblyInformationProvider"/> for the <see cref="WatchdogBase"/>.</param>
|
||||
/// <param name="logger">The <see cref="ILogger"/> for the <see cref="WatchdogBase"/>.</param>
|
||||
/// <param name="initialLaunchParameters">The <see cref="DreamDaemonLaunchParameters"/> for the <see cref="WatchdogBase"/>.</param>
|
||||
/// <param name="instance">The <see cref="Api.Models.Instance"/> for the <see cref="WatchdogBase"/>.</param>
|
||||
@@ -75,7 +73,6 @@ namespace Tgstation.Server.Host.Components.Watchdog
|
||||
IJobManager jobManager,
|
||||
IServerControl serverControl,
|
||||
IAsyncDelayer asyncDelayer,
|
||||
IAssemblyInformationProvider assemblyInformationProvider,
|
||||
ILogger<ExperimentalWatchdog> logger,
|
||||
DreamDaemonLaunchParameters initialLaunchParameters,
|
||||
Api.Models.Instance instance, bool autoStart)
|
||||
@@ -88,7 +85,6 @@ namespace Tgstation.Server.Host.Components.Watchdog
|
||||
jobManager,
|
||||
serverControl,
|
||||
asyncDelayer,
|
||||
assemblyInformationProvider,
|
||||
logger,
|
||||
initialLaunchParameters,
|
||||
instance,
|
||||
|
||||
@@ -17,7 +17,6 @@ using Tgstation.Server.Host.Core;
|
||||
using Tgstation.Server.Host.Database;
|
||||
using Tgstation.Server.Host.Extensions;
|
||||
using Tgstation.Server.Host.Jobs;
|
||||
using Tgstation.Server.Host.System;
|
||||
|
||||
namespace Tgstation.Server.Host.Components.Watchdog
|
||||
{
|
||||
@@ -113,11 +112,6 @@ namespace Tgstation.Server.Host.Components.Watchdog
|
||||
/// </summary>
|
||||
readonly IRestartRegistration restartRegistration;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="IAssemblyInformationProvider"/> for the <see cref="WatchdogBase"/>.
|
||||
/// </summary>
|
||||
readonly IAssemblyInformationProvider assemblyInformationProvider;
|
||||
|
||||
/// <summary>
|
||||
/// If the <see cref="WatchdogBase"/> should <see cref="LaunchImplNoLock(bool, bool, DualReattachInformation, CancellationToken)"/> in <see cref="StartAsync(CancellationToken)"/>
|
||||
/// </summary>
|
||||
@@ -164,7 +158,6 @@ namespace Tgstation.Server.Host.Components.Watchdog
|
||||
/// <param name="jobManager">The value of <see cref="jobManager"/></param>
|
||||
/// <param name="serverControl">The <see cref="IServerControl"/> to populate <see cref="restartRegistration"/> with</param>
|
||||
/// <param name="asyncDelayer">The value of <see cref="AsyncDelayer"/>.</param>
|
||||
/// <param name="assemblyInformationProvider">The value of <see cref="assemblyInformationProvider"/></param>
|
||||
/// <param name="logger">The value of <see cref="Logger"/></param>
|
||||
/// <param name="initialLaunchParameters">The initial value of <see cref="ActiveLaunchParameters"/>. May be modified</param>
|
||||
/// <param name="instance">The value of <see cref="instance"/></param>
|
||||
@@ -178,7 +171,6 @@ namespace Tgstation.Server.Host.Components.Watchdog
|
||||
IJobManager jobManager,
|
||||
IServerControl serverControl,
|
||||
IAsyncDelayer asyncDelayer,
|
||||
IAssemblyInformationProvider assemblyInformationProvider,
|
||||
ILogger logger,
|
||||
DreamDaemonLaunchParameters initialLaunchParameters,
|
||||
Api.Models.Instance instance,
|
||||
@@ -191,7 +183,6 @@ namespace Tgstation.Server.Host.Components.Watchdog
|
||||
this.databaseContextFactory = databaseContextFactory ?? throw new ArgumentNullException(nameof(databaseContextFactory));
|
||||
this.jobManager = jobManager ?? throw new ArgumentNullException(nameof(jobManager));
|
||||
AsyncDelayer = asyncDelayer ?? throw new ArgumentNullException(nameof(asyncDelayer));
|
||||
this.assemblyInformationProvider = assemblyInformationProvider ?? throw new ArgumentNullException(nameof(assemblyInformationProvider));
|
||||
Logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
||||
ActiveLaunchParameters = initialLaunchParameters ?? throw new ArgumentNullException(nameof(initialLaunchParameters));
|
||||
this.instance = instance ?? throw new ArgumentNullException(nameof(instance));
|
||||
@@ -870,14 +861,6 @@ namespace Tgstation.Server.Host.Components.Watchdog
|
||||
{
|
||||
using (await SemaphoreSlimContext.Lock(Semaphore, ct).ConfigureAwait(false))
|
||||
await LaunchImplNoLock(true, true, reattachInfo, ct).ConfigureAwait(false);
|
||||
|
||||
if (!Running)
|
||||
return;
|
||||
var server = GetActiveController();
|
||||
if (server == null)
|
||||
return;
|
||||
|
||||
await server.SendCommand(new TopicParameters(assemblyInformationProvider.Version), cancellationToken).ConfigureAwait(false);
|
||||
}, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@ using Tgstation.Server.Host.Core;
|
||||
using Tgstation.Server.Host.Database;
|
||||
using Tgstation.Server.Host.IO;
|
||||
using Tgstation.Server.Host.Jobs;
|
||||
using Tgstation.Server.Host.System;
|
||||
|
||||
namespace Tgstation.Server.Host.Components.Watchdog
|
||||
{
|
||||
@@ -42,11 +41,6 @@ namespace Tgstation.Server.Host.Components.Watchdog
|
||||
/// </summary>
|
||||
protected IAsyncDelayer AsyncDelayer { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="IAssemblyInformationProvider"/> for the <see cref="WatchdogFactory"/>
|
||||
/// </summary>
|
||||
protected IAssemblyInformationProvider AssemblyInformationProvider { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="Configuration.GeneralConfiguration"/> for the <see cref="WatchdogFactory"/>
|
||||
/// </summary>
|
||||
@@ -60,7 +54,6 @@ namespace Tgstation.Server.Host.Components.Watchdog
|
||||
/// <param name="databaseContextFactory">The value of <see cref="DatabaseContextFactory"/></param>
|
||||
/// <param name="jobManager">The value of <see cref="JobManager"/></param>
|
||||
/// <param name="asyncDelayer">The value of <see cref="AsyncDelayer"/></param>
|
||||
/// <param name="assemblyInformationProvider">The value of <see cref="AssemblyInformationProvider"/>.</param>
|
||||
/// <param name="generalConfigurationOptions">The <see cref="IOptions{TOptions}"/> containing the value of <see cref="GeneralConfiguration"/></param>
|
||||
public WatchdogFactory(
|
||||
IServerControl serverControl,
|
||||
@@ -68,7 +61,6 @@ namespace Tgstation.Server.Host.Components.Watchdog
|
||||
IDatabaseContextFactory databaseContextFactory,
|
||||
IJobManager jobManager,
|
||||
IAsyncDelayer asyncDelayer,
|
||||
IAssemblyInformationProvider assemblyInformationProvider,
|
||||
IOptions<GeneralConfiguration> generalConfigurationOptions)
|
||||
{
|
||||
ServerControl = serverControl ?? throw new ArgumentNullException(nameof(serverControl));
|
||||
@@ -76,7 +68,6 @@ namespace Tgstation.Server.Host.Components.Watchdog
|
||||
DatabaseContextFactory = databaseContextFactory ?? throw new ArgumentNullException(nameof(databaseContextFactory));
|
||||
JobManager = jobManager ?? throw new ArgumentNullException(nameof(jobManager));
|
||||
AsyncDelayer = asyncDelayer ?? throw new ArgumentNullException(nameof(asyncDelayer));
|
||||
AssemblyInformationProvider = assemblyInformationProvider ?? throw new ArgumentNullException(nameof(assemblyInformationProvider));
|
||||
GeneralConfiguration = generalConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(generalConfigurationOptions));
|
||||
}
|
||||
|
||||
@@ -100,7 +91,6 @@ namespace Tgstation.Server.Host.Components.Watchdog
|
||||
JobManager,
|
||||
ServerControl,
|
||||
AsyncDelayer,
|
||||
AssemblyInformationProvider,
|
||||
LoggerFactory.CreateLogger<ExperimentalWatchdog>(),
|
||||
settings,
|
||||
instance,
|
||||
@@ -137,7 +127,6 @@ namespace Tgstation.Server.Host.Components.Watchdog
|
||||
JobManager,
|
||||
ServerControl,
|
||||
AsyncDelayer,
|
||||
AssemblyInformationProvider,
|
||||
LoggerFactory.CreateLogger<BasicWatchdog>(),
|
||||
settings,
|
||||
instance,
|
||||
|
||||
@@ -10,7 +10,6 @@ using Tgstation.Server.Host.Core;
|
||||
using Tgstation.Server.Host.Database;
|
||||
using Tgstation.Server.Host.IO;
|
||||
using Tgstation.Server.Host.Jobs;
|
||||
using Tgstation.Server.Host.System;
|
||||
|
||||
namespace Tgstation.Server.Host.Components.Watchdog
|
||||
{
|
||||
@@ -54,7 +53,6 @@ namespace Tgstation.Server.Host.Components.Watchdog
|
||||
/// <param name="databaseContextFactory">The <see cref="IDatabaseContextFactory"/> for the <see cref="WatchdogBase"/>.</param>
|
||||
/// <param name="jobManager">The <see cref="IJobManager"/> for the <see cref="WatchdogBase"/>.</param>
|
||||
/// <param name="serverControl">The <see cref="IServerControl"/> for the <see cref="WatchdogBase"/>.</param>
|
||||
/// <param name="assemblyInformationProvider">The <see cref="IAssemblyInformationProvider"/> for the <see cref="WatchdogBase"/>.</param>
|
||||
/// <param name="asyncDelayer">The <see cref="IAsyncDelayer"/> for the <see cref="WatchdogBase"/>.</param>
|
||||
/// <param name="ioManager">The value of <see cref="ioManager"/>.</param>
|
||||
/// <param name="symlinkFactory">The value of <see cref="symlinkFactory"/>.</param>
|
||||
@@ -71,7 +69,6 @@ namespace Tgstation.Server.Host.Components.Watchdog
|
||||
IJobManager jobManager,
|
||||
IServerControl serverControl,
|
||||
IAsyncDelayer asyncDelayer,
|
||||
IAssemblyInformationProvider assemblyInformationProvider,
|
||||
IIOManager ioManager,
|
||||
ISymlinkFactory symlinkFactory,
|
||||
ILogger<WindowsWatchdog> logger,
|
||||
@@ -86,7 +83,6 @@ namespace Tgstation.Server.Host.Components.Watchdog
|
||||
jobManager,
|
||||
serverControl,
|
||||
asyncDelayer,
|
||||
assemblyInformationProvider,
|
||||
logger,
|
||||
initialLaunchParameters,
|
||||
instance,
|
||||
|
||||
@@ -10,7 +10,6 @@ using Tgstation.Server.Host.Core;
|
||||
using Tgstation.Server.Host.Database;
|
||||
using Tgstation.Server.Host.IO;
|
||||
using Tgstation.Server.Host.Jobs;
|
||||
using Tgstation.Server.Host.System;
|
||||
|
||||
namespace Tgstation.Server.Host.Components.Watchdog
|
||||
{
|
||||
@@ -32,7 +31,6 @@ namespace Tgstation.Server.Host.Components.Watchdog
|
||||
/// <param name="databaseContextFactory">The <see cref="IDatabaseContextFactory"/> for the <see cref="WatchdogFactory"/>.</param>
|
||||
/// <param name="jobManager">The <see cref="IJobManager"/> for the <see cref="WatchdogFactory"/>.</param>
|
||||
/// <param name="asyncDelayer">The <see cref="IAsyncDelayer"/> for the <see cref="WatchdogFactory"/>.</param>
|
||||
/// <param name="assemblyInformationProvider">The <see cref="IAssemblyInformationProvider"/> for the <see cref="WatchdogFactory"/>.</param>
|
||||
/// <param name="symlinkFactory">The value of <see cref="symlinkFactory"/>.</param>
|
||||
/// <param name="generalConfigurationOptions">The <see cref="IOptions{TOptions}"/> for <see cref="GeneralConfiguration"/> for the <see cref="WatchdogFactory"/>.</param>
|
||||
public WindowsWatchdogFactory(
|
||||
@@ -41,7 +39,6 @@ namespace Tgstation.Server.Host.Components.Watchdog
|
||||
IDatabaseContextFactory databaseContextFactory,
|
||||
IJobManager jobManager,
|
||||
IAsyncDelayer asyncDelayer,
|
||||
IAssemblyInformationProvider assemblyInformationProvider,
|
||||
ISymlinkFactory symlinkFactory,
|
||||
IOptions<GeneralConfiguration> generalConfigurationOptions)
|
||||
: base(
|
||||
@@ -50,7 +47,6 @@ namespace Tgstation.Server.Host.Components.Watchdog
|
||||
databaseContextFactory,
|
||||
jobManager,
|
||||
asyncDelayer,
|
||||
assemblyInformationProvider,
|
||||
generalConfigurationOptions)
|
||||
{
|
||||
this.symlinkFactory = symlinkFactory ?? throw new ArgumentNullException(nameof(symlinkFactory));
|
||||
@@ -74,7 +70,6 @@ namespace Tgstation.Server.Host.Components.Watchdog
|
||||
JobManager,
|
||||
ServerControl,
|
||||
AsyncDelayer,
|
||||
AssemblyInformationProvider,
|
||||
ioManager,
|
||||
symlinkFactory,
|
||||
LoggerFactory.CreateLogger<WindowsWatchdog>(),
|
||||
|
||||
@@ -12,6 +12,7 @@ using System.Net.Mime;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Tgstation.Server.Api;
|
||||
using Tgstation.Server.Host.Components.Interop;
|
||||
using Tgstation.Server.Host.Configuration;
|
||||
using Tgstation.Server.Host.Core;
|
||||
using Tgstation.Server.Host.Database;
|
||||
@@ -124,6 +125,7 @@ namespace Tgstation.Server.Host.Controllers
|
||||
{
|
||||
Version = assemblyInformationProvider.Version,
|
||||
ApiVersion = ApiHeaders.Version,
|
||||
DMApiVersion = DMApiConstants.Version,
|
||||
MinimumPasswordLength = generalConfiguration.MinimumPasswordLength,
|
||||
InstanceLimit = generalConfiguration.InstanceLimit,
|
||||
UserLimit = generalConfiguration.UserLimit,
|
||||
|
||||
@@ -25,7 +25,7 @@ using Tgstation.Server.Host.Components;
|
||||
using Tgstation.Server.Host.Components.Byond;
|
||||
using Tgstation.Server.Host.Components.Chat;
|
||||
using Tgstation.Server.Host.Components.Chat.Providers;
|
||||
using Tgstation.Server.Host.Components.Interop;
|
||||
using Tgstation.Server.Host.Components.Interop.Bridge;
|
||||
using Tgstation.Server.Host.Components.Interop.Converters;
|
||||
using Tgstation.Server.Host.Components.Repository;
|
||||
using Tgstation.Server.Host.Components.Watchdog;
|
||||
|
||||
@@ -247,6 +247,7 @@ namespace Tgstation.Server.Host.Database
|
||||
/// <inheritdoc />
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
// Setup our more complex database relations
|
||||
Logger.LogTrace("Building entity framework context...");
|
||||
base.OnModelCreating(modelBuilder);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user