mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-26 14:37:44 +01:00
Event for successful DD launches
This commit is contained in:
+1
-1
@@ -8,7 +8,7 @@
|
||||
<TgsApiVersion>9.0.1</TgsApiVersion>
|
||||
<TgsApiLibraryVersion>9.0.0</TgsApiLibraryVersion>
|
||||
<TgsClientVersion>10.0.0</TgsClientVersion>
|
||||
<TgsDmapiVersion>6.0.3</TgsDmapiVersion>
|
||||
<TgsDmapiVersion>6.0.4</TgsDmapiVersion>
|
||||
<TgsInteropVersion>5.3.0</TgsInteropVersion>
|
||||
<TgsHostWatchdogVersion>1.1.1</TgsHostWatchdogVersion>
|
||||
<TgsContainerScriptVersion>1.2.0</TgsContainerScriptVersion>
|
||||
|
||||
@@ -102,6 +102,8 @@
|
||||
// #define TGS_EVENT_WORLD_REBOOT 20
|
||||
/// Watchdog event when TgsInitializationComplete() is called. No parameters.
|
||||
#define TGS_EVENT_WORLD_PRIME 21
|
||||
// DMAPI also doesnt implement this
|
||||
// #define TGS_EVENT_WATCHEDOG_LAUNCH_SUCCESS 22
|
||||
|
||||
// OTHER ENUMS
|
||||
|
||||
|
||||
@@ -230,7 +230,7 @@ namespace Tgstation.Server.Host.Components.Deployment
|
||||
|
||||
ApiValidationStatus validationStatus;
|
||||
using (var provider = new TemporaryDmbProvider(ioManager.ResolvePath(job.DirectoryName.ToString()), String.Concat(job.DmeName, DmbExtension), job))
|
||||
await using (var controller = await sessionControllerFactory.LaunchNew(provider, byondLock, launchParameters, true, cancellationToken).ConfigureAwait(false))
|
||||
await using (var controller = await sessionControllerFactory.LaunchNew(provider, byondLock, launchParameters, true, false, cancellationToken).ConfigureAwait(false))
|
||||
{
|
||||
var launchResult = await controller.LaunchResult.ConfigureAwait(false);
|
||||
|
||||
|
||||
@@ -137,5 +137,11 @@ namespace Tgstation.Server.Host.Components.Events
|
||||
/// </summary>
|
||||
[EventScript("WorldPrime")]
|
||||
WorldPrime,
|
||||
|
||||
/// <summary>
|
||||
/// After the watchdog has launched successfully. Parameters: PID of DreamDaemon
|
||||
/// </summary>
|
||||
[EventScript("WatchdogSuccessfulLaunch")]
|
||||
WatchdogSuccessfulLaunch,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -273,7 +273,8 @@ namespace Tgstation.Server.Host.Components
|
||||
serverPortProvider,
|
||||
loggerFactory,
|
||||
loggerFactory.CreateLogger<SessionControllerFactory>(),
|
||||
metadata);
|
||||
metadata,
|
||||
eventConsumer);
|
||||
|
||||
var dmbFactory = new DmbFactory(
|
||||
databaseContextFactory,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System.Threading;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Tgstation.Server.Api.Models.Internal;
|
||||
using Tgstation.Server.Host.Components.Byond;
|
||||
@@ -18,6 +18,7 @@ namespace Tgstation.Server.Host.Components.Session
|
||||
/// <param name="currentByondLock">The current <see cref="IByondExecutableLock"/> if any</param>
|
||||
/// <param name="launchParameters">The <see cref="DreamDaemonLaunchParameters"/> to use. <see cref="DreamDaemonLaunchParameters.SecurityLevel"/> will be updated with the minumum required security level for the launch.</param>
|
||||
/// <param name="apiValidate">If the <see cref="ISessionController"/> should only validate the DMAPI then exit</param>
|
||||
/// <param name="isProduction">If the <see cref="ISessionController"/> is starting a production DD and not a staging DD</param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation</param>
|
||||
/// <returns>A <see cref="Task{TResult}"/> resulting in a new <see cref="ISessionController"/></returns>
|
||||
Task<ISessionController> LaunchNew(
|
||||
@@ -25,6 +26,7 @@ namespace Tgstation.Server.Host.Components.Session
|
||||
IByondExecutableLock currentByondLock,
|
||||
DreamDaemonLaunchParameters launchParameters,
|
||||
bool apiValidate,
|
||||
bool isProduction,
|
||||
CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Net.Sockets;
|
||||
using System.Text;
|
||||
@@ -11,6 +12,7 @@ using Tgstation.Server.Api.Models.Internal;
|
||||
using Tgstation.Server.Host.Components.Byond;
|
||||
using Tgstation.Server.Host.Components.Chat;
|
||||
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.Core;
|
||||
@@ -95,6 +97,11 @@ namespace Tgstation.Server.Host.Components.Session
|
||||
/// </summary>
|
||||
readonly Api.Models.Instance instance;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="IEventConsumer"/> for the <see cref="SessionControllerFactory"/>
|
||||
/// </summary>
|
||||
private IEventConsumer EventConsumer { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Change a given <paramref name="securityLevel"/> into the appropriate DreamDaemon command line word
|
||||
/// </summary>
|
||||
@@ -145,6 +152,7 @@ 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>
|
||||
public SessionControllerFactory(
|
||||
IProcessExecutor processExecutor,
|
||||
IByondManager byond,
|
||||
@@ -159,7 +167,8 @@ namespace Tgstation.Server.Host.Components.Session
|
||||
IServerPortProvider serverPortProvider,
|
||||
ILoggerFactory loggerFactory,
|
||||
ILogger<SessionControllerFactory> logger,
|
||||
Api.Models.Instance instance)
|
||||
Api.Models.Instance instance,
|
||||
EventConsumer eventConsumer)
|
||||
{
|
||||
this.processExecutor = processExecutor ?? throw new ArgumentNullException(nameof(processExecutor));
|
||||
this.byond = byond ?? throw new ArgumentNullException(nameof(byond));
|
||||
@@ -175,6 +184,7 @@ namespace Tgstation.Server.Host.Components.Session
|
||||
this.serverPortProvider = serverPortProvider ?? throw new ArgumentNullException(nameof(serverPortProvider));
|
||||
this.loggerFactory = loggerFactory ?? throw new ArgumentNullException(nameof(loggerFactory));
|
||||
this.logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
||||
EventConsumer = eventConsumer ?? throw new ArgumentNullException(nameof(eventConsumer));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -184,6 +194,7 @@ namespace Tgstation.Server.Host.Components.Session
|
||||
IByondExecutableLock currentByondLock,
|
||||
DreamDaemonLaunchParameters launchParameters,
|
||||
bool apiValidate,
|
||||
bool isProduction,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
logger.LogTrace("Begin session launch...");
|
||||
@@ -266,6 +277,14 @@ namespace Tgstation.Server.Host.Components.Session
|
||||
noShellExecute,
|
||||
noShellExecute: noShellExecute);
|
||||
|
||||
// If this isnt a staging DD (Deployment DD), fire off an event
|
||||
if(isProduction) {
|
||||
await EventConsumer.HandleEvent(EventType.WatchdogSuccessfulLaunch, new List<string>
|
||||
{
|
||||
process.Id.ToString(CultureInfo.InvariantCulture)
|
||||
}, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
async Task<string> GetDDOutput()
|
||||
{
|
||||
// DCT x2: None available
|
||||
|
||||
@@ -210,6 +210,7 @@ namespace Tgstation.Server.Host.Components.Watchdog
|
||||
null,
|
||||
ActiveLaunchParameters,
|
||||
false,
|
||||
true,
|
||||
cancellationToken);
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user