tgstation-server 6.19.1
The /tg/station 13 server suite
Loading...
Searching...
No Matches
SessionControllerFactory.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3using System.Globalization;
4using System.Linq;
5using System.Net.Sockets;
6using System.Text;
7using System.Threading;
8using System.Threading.Tasks;
9
10using Microsoft.Extensions.Logging;
11using Microsoft.Extensions.Options;
12
13using Prometheus;
14
32
34{
37 {
41 const string DreamDaemonLogsPath = "DreamDaemonLogs";
42
47
52
57
62
67
72
77
82
87
92
97
102
107
112
117
122
127
131 readonly ILoggerFactory loggerFactory;
132
136 readonly IOptionsMonitor<SessionConfiguration> sessionConfigurationOptions;
137
141 readonly ILogger<SessionControllerFactory> logger;
142
146 readonly Counter sessionsLaunched;
147
151 readonly Gauge lastSessionLaunch;
152
157
165 async ValueTask PortBindTest(ushort port, EngineType engineType, CancellationToken cancellationToken)
166 {
167 logger.LogTrace("Bind test: {port}", port);
168 try
169 {
170 // GIVE ME THE FUCKING PORT BACK WINDOWS!!!!
171 const int MaxAttempts = 5;
172 for (var i = 0; i < MaxAttempts; ++i)
173 try
174 {
175 SocketExtensions.BindTest(platformIdentifier, port, false, engineType == EngineType.OpenDream);
176 if (i > 0)
177 logger.LogDebug("Clearing the socket took {iterations} attempts :/", i + 1);
178
179 break;
180 }
181 catch (SocketException ex) when (platformIdentifier.IsWindows && ex.SocketErrorCode == SocketError.AddressAlreadyInUse && i < (MaxAttempts - 1))
182 {
183 await asyncDelayer.Delay(TimeSpan.FromSeconds(1), cancellationToken);
184 }
185 }
186 catch (SocketException ex) when (ex.SocketErrorCode == SocketError.AddressAlreadyInUse)
187 {
188 throw new JobException(ErrorCode.GameServerPortInUse, ex);
189 }
190 }
191
235 IMetricFactory metricFactory,
236 ILoggerFactory loggerFactory,
237 IOptionsMonitor<SessionConfiguration> sessionConfigurationOptions,
238 ILogger<SessionControllerFactory> logger,
239 Api.Models.Instance instance)
240 {
241 this.processExecutor = processExecutor ?? throw new ArgumentNullException(nameof(processExecutor));
242 this.engineManager = engineManager ?? throw new ArgumentNullException(nameof(engineManager));
243 this.topicClientFactory = topicClientFactory ?? throw new ArgumentNullException(nameof(topicClientFactory));
244 this.cryptographySuite = cryptographySuite ?? throw new ArgumentNullException(nameof(cryptographySuite));
245 this.assemblyInformationProvider = assemblyInformationProvider ?? throw new ArgumentNullException(nameof(assemblyInformationProvider));
246 this.gameIOManager = gameIOManager ?? throw new ArgumentNullException(nameof(gameIOManager));
247 this.diagnosticsIOManager = diagnosticsIOManager ?? throw new ArgumentNullException(nameof(diagnosticsIOManager));
248 this.chat = chat ?? throw new ArgumentNullException(nameof(chat));
249 this.networkPromptReaper = networkPromptReaper ?? throw new ArgumentNullException(nameof(networkPromptReaper));
250 this.platformIdentifier = platformIdentifier ?? throw new ArgumentNullException(nameof(platformIdentifier));
251 this.bridgeRegistrar = bridgeRegistrar ?? throw new ArgumentNullException(nameof(bridgeRegistrar));
252 this.serverPortProvider = serverPortProvider ?? throw new ArgumentNullException(nameof(serverPortProvider));
253 this.eventConsumer = eventConsumer ?? throw new ArgumentNullException(nameof(eventConsumer));
254 this.jobManager = jobManager ?? throw new ArgumentNullException(nameof(jobManager));
255 this.dreamMaker = dreamMaker ?? throw new ArgumentNullException(nameof(dreamMaker));
256 this.asyncDelayer = asyncDelayer ?? throw new ArgumentNullException(nameof(asyncDelayer));
257 this.dotnetDumpService = dotnetDumpService ?? throw new ArgumentNullException(nameof(dotnetDumpService));
258 ArgumentNullException.ThrowIfNull(metricFactory);
259 this.sessionConfigurationOptions = sessionConfigurationOptions ?? throw new ArgumentNullException(nameof(sessionConfigurationOptions));
260 this.loggerFactory = loggerFactory ?? throw new ArgumentNullException(nameof(loggerFactory));
261 this.logger = logger ?? throw new ArgumentNullException(nameof(logger));
262 this.instance = instance ?? throw new ArgumentNullException(nameof(instance));
263
264 sessionsLaunched = metricFactory.CreateCounter("tgs_sessions_launched", "The number of game server processes created");
265 lastSessionLaunch = metricFactory.CreateGauge("tgs_session_start_time", "The UTC unix timestamp the most recent session was started");
266 }
267
269#pragma warning disable CA1506 // TODO: Decomplexify
270 public async ValueTask<ISessionController> LaunchNew(
271 IDmbProvider dmbProvider,
272 IEngineExecutableLock? currentByondLock,
273 DreamDaemonLaunchParameters launchParameters,
274 bool apiValidate,
275 CancellationToken cancellationToken)
276 {
277 logger.LogTrace("Begin session launch...");
278 if (!launchParameters.Port.HasValue)
279 throw new InvalidOperationException("Given port is null!");
280
281 switch (dmbProvider.CompileJob.MinimumSecurityLevel)
282 {
283 case DreamDaemonSecurity.Ultrasafe:
284 break;
285 case DreamDaemonSecurity.Safe:
286 if (launchParameters.SecurityLevel == DreamDaemonSecurity.Ultrasafe)
287 {
288 logger.LogTrace("Boosting security level to minimum of Safe");
289 launchParameters.SecurityLevel = DreamDaemonSecurity.Safe;
290 }
291
292 break;
293 case DreamDaemonSecurity.Trusted:
294 if (launchParameters.SecurityLevel != DreamDaemonSecurity.Trusted)
295 logger.LogTrace("Boosting security level to minimum of Trusted");
296
297 launchParameters.SecurityLevel = DreamDaemonSecurity.Trusted;
298 break;
299 default:
300 throw new InvalidOperationException(String.Format(CultureInfo.InvariantCulture, "Invalid DreamDaemonSecurity value: {0}", dmbProvider.CompileJob.MinimumSecurityLevel));
301 }
302
303 // get the byond lock
304 var engineLock = currentByondLock ?? await engineManager.UseExecutables(
305 dmbProvider.EngineVersion,
306 gameIOManager.ConcatPath(dmbProvider.Directory, dmbProvider.DmbName),
307 cancellationToken);
308 try
309 {
310 logger.LogDebug(
311 "Launching session with CompileJob {compileJobId}...",
312 dmbProvider.CompileJob.Id);
313
314 // mad this isn't abstracted but whatever
315 var engineType = dmbProvider.EngineVersion.Engine!.Value;
316 if (engineType == EngineType.Byond)
318
319 await PortBindTest(launchParameters.Port.Value, engineType, cancellationToken);
320
321 string? outputFilePath = null;
322 var preserveLogFile = true;
323
324 var hasStandardOutput = engineLock.HasStandardOutput;
325 if (launchParameters.LogOutput!.Value)
326 {
327 var now = DateTimeOffset.UtcNow;
328 var dateDirectory = diagnosticsIOManager.ConcatPath(DreamDaemonLogsPath, now.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture));
329 await diagnosticsIOManager.CreateDirectory(dateDirectory, cancellationToken);
330 outputFilePath = diagnosticsIOManager.ResolvePath(
332 dateDirectory,
333 $"server-utc-{now.ToString("yyyy-MM-dd-HH-mm-ss", CultureInfo.InvariantCulture)}{(apiValidate ? "-dmapi" : String.Empty)}.log"));
334
335 logger.LogInformation("Logging server output to {path}...", outputFilePath);
336 }
337 else if (!hasStandardOutput)
338 {
339 outputFilePath = gameIOManager.ConcatPath(dmbProvider.Directory, $"{Guid.NewGuid()}.server.log");
340 preserveLogFile = false;
341 }
342
343 var accessIdentifier = cryptographySuite.GetSecureString();
344
345 if (!apiValidate && dmbProvider.CompileJob.DMApiVersion == null)
346 logger.LogDebug("Session will have no DMAPI support!");
347
348 // launch dd
349 var process = await CreateGameServerProcess(
350 dmbProvider,
351 engineLock,
352 launchParameters,
353 accessIdentifier,
354 outputFilePath,
355 apiValidate,
356 cancellationToken);
357
358 try
359 {
360 var chatTrackingContext = chat.CreateTrackingContext();
361
362 try
363 {
364 var runtimeInformation = CreateRuntimeInformation(
365 dmbProvider,
366 chatTrackingContext,
367 launchParameters.SecurityLevel!.Value,
368 launchParameters.Visibility!.Value,
369 apiValidate);
370
371 var reattachInformation = new ReattachInformation(
372 dmbProvider,
373 process,
374 runtimeInformation,
375 accessIdentifier,
376 launchParameters.Port.Value);
377
378 var byondTopicSender = topicClientFactory.CreateTopicClient(
379 TimeSpan.FromMilliseconds(
380 launchParameters.TopicRequestTimeout!.Value));
381
382 var sessionController = new SessionController(
383 reattachInformation,
384 instance,
385 process,
386 engineLock,
387 byondTopicSender,
388 chatTrackingContext,
390 chat,
397 loggerFactory.CreateLogger<SessionController>(),
398 () => LogDDOutput(
399 process,
400 outputFilePath,
401 hasStandardOutput,
402 preserveLogFile,
403 CancellationToken.None), // DCT: None available
404 launchParameters.StartupTimeout,
405 false,
406 apiValidate);
407
408 if (!apiValidate)
409 {
410 sessionsLaunched.Inc();
411 lastSessionLaunch.SetToCurrentTimeUtc();
412 }
413
414 return sessionController;
415 }
416 catch
417 {
418 chatTrackingContext.Dispose();
419 throw;
420 }
421 }
422 catch
423 {
424 await using (process)
425 {
426 process.Terminate();
427 await process.Lifetime;
428 throw;
429 }
430 }
431 }
432 catch
433 {
434 if (currentByondLock == null)
435 engineLock.Dispose();
436 throw;
437 }
438 }
439#pragma warning restore CA1506
440
442 public async ValueTask<ISessionController?> Reattach(
443 ReattachInformation reattachInformation,
444 CancellationToken cancellationToken)
445 {
446 ArgumentNullException.ThrowIfNull(reattachInformation);
447
448 logger.LogTrace("Begin session reattach...");
449 var byondTopicSender = topicClientFactory.CreateTopicClient(reattachInformation.TopicRequestTimeout);
450 var engineLock = await engineManager.UseExecutables(
451 reattachInformation.Dmb.EngineVersion,
452 null, // Doesn't matter if it's trusted or not on reattach
453 cancellationToken);
454
455 try
456 {
457 logger.LogDebug(
458 "Attaching to session PID: {pid}, CompileJob: {compileJobId}...",
459 reattachInformation.ProcessId,
460 reattachInformation.Dmb.CompileJob.Id);
461
462 var process = processExecutor.GetProcess(reattachInformation.ProcessId);
463 if (process == null)
464 return null;
465
466 try
467 {
468 if (engineLock.PromptsForNetworkAccess)
470
471 var chatTrackingContext = chat.CreateTrackingContext();
472 try
473 {
474 var runtimeInformation = CreateRuntimeInformation(
475 reattachInformation.Dmb,
476 chatTrackingContext,
477 reattachInformation.LaunchSecurityLevel,
478 reattachInformation.LaunchVisibility,
479 false);
480 reattachInformation.SetRuntimeInformation(runtimeInformation);
481
482 var controller = new SessionController(
483 reattachInformation,
484 instance,
485 process,
486 engineLock,
487 byondTopicSender,
488 chatTrackingContext,
490 chat,
497 loggerFactory.CreateLogger<SessionController>(),
498 () => ValueTask.CompletedTask,
499 null,
500 true,
501 false);
502
503 process = null;
504 engineLock = null;
505 chatTrackingContext = null;
506
507 return controller;
508 }
509 catch
510 {
511 chatTrackingContext?.Dispose();
512 throw;
513 }
514 }
515 catch
516 {
517 if (process != null)
518 await process.DisposeAsync();
519
520 throw;
521 }
522 }
523 catch
524 {
525 engineLock?.Dispose();
526 throw;
527 }
528 }
529
541 async ValueTask<IProcess> CreateGameServerProcess(
542 IDmbProvider dmbProvider,
543 IEngineExecutableLock engineLock,
544 DreamDaemonLaunchParameters launchParameters,
545 string accessIdentifier,
546 string? logFilePath,
547 bool apiValidate,
548 CancellationToken cancellationToken)
549 {
550 var serverMayHaveDMApi = apiValidate || dmbProvider.CompileJob.DMApiVersion != null;
551
552 var serverArguments = serverMayHaveDMApi
553 ? new Dictionary<string, string>
554 {
556 { DMApiConstants.ParamServerPort, serverPortProvider.HttpApiPort.ToString(CultureInfo.InvariantCulture) },
557 { DMApiConstants.ParamAccessIdentifier, accessIdentifier },
558 }
559 : null;
560
561 var environment = await engineLock.LoadEnv(logger, false, cancellationToken);
562 var arguments = engineLock.FormatServerArguments(
563 dmbProvider,
564 serverArguments,
565 launchParameters,
566 accessIdentifier,
567 !engineLock.HasStandardOutput || engineLock.PreferFileLogging
568 ? logFilePath
569 : null);
570
571 // If this isnt a staging DD (From a Deployment), fire off events
572 if (!apiValidate)
574 EventType.DreamDaemonPreLaunch,
575 Enumerable.Empty<string?>(),
576 false,
577 false,
578 cancellationToken);
579
580 var process = await processExecutor.LaunchProcess(
581 engineLock.ServerExePath,
582 dmbProvider.Directory,
583 arguments,
584 cancellationToken,
585 environment,
586 logFilePath,
587 engineLock.HasStandardOutput,
588 true);
589
590 try
591 {
592 var sessionConfiguration = sessionConfigurationOptions.CurrentValue;
593 if (!apiValidate)
594 {
595 if (sessionConfiguration.HighPriorityLiveDreamDaemon)
596 process.AdjustPriority(true);
597 }
598 else if (sessionConfiguration.LowPriorityDeploymentProcesses)
599 process.AdjustPriority(false);
600
601 if (!engineLock.HasStandardOutput)
603
604 if (!apiValidate)
606 EventType.DreamDaemonLaunch,
607 new List<string>
608 {
609 process.Id.ToString(CultureInfo.InvariantCulture),
610 },
611 false,
612 false,
613 cancellationToken);
614
615 return process;
616 }
617 catch
618 {
619 await using (process)
620 {
621 process.Terminate();
622 await process.Lifetime;
623 throw;
624 }
625 }
626 }
627
637 async ValueTask LogDDOutput(IProcess process, string? outputFilePath, bool cliSupported, bool preserveFile, CancellationToken cancellationToken)
638 {
639 try
640 {
641 string? ddOutput = null;
642 if (cliSupported)
643 ddOutput = (await process.GetCombinedOutput(cancellationToken))!;
644
645 if (String.IsNullOrWhiteSpace(ddOutput) && outputFilePath != null)
646 try
647 {
648 var dreamDaemonLogBytes = await gameIOManager.ReadAllBytes(
649 outputFilePath,
650 cancellationToken);
651
652 ddOutput = Encoding.UTF8.GetString(dreamDaemonLogBytes);
653 }
654 finally
655 {
656 if (!preserveFile)
657 try
658 {
659 logger.LogTrace("Deleting temporary log file {path}...", outputFilePath);
660 await gameIOManager.DeleteFile(outputFilePath, cancellationToken);
661 }
662 catch (Exception ex)
663 {
664 // this is expected on OD at time of the support changes.
665 // I've open a change to fix it: https://github.com/space-wizards/RobustToolbox/pull/4501
666 logger.LogWarning(ex, "Failed to delete server log file {outputFilePath}!", outputFilePath);
667 }
668 }
669
670 logger.LogTrace(
671 "Server Output:{newLine}{output}",
672 Environment.NewLine,
673 ddOutput);
674 }
675 catch (Exception ex)
676 {
677 logger.LogWarning(ex, "Error reading server output!");
678 }
679 }
680
691 IDmbProvider dmbProvider,
692 IChatTrackingContext chatTrackingContext,
693 DreamDaemonSecurity securityLevel,
694 DreamDaemonVisibility visibility,
695 bool apiValidateOnly)
696 => new(
697 chatTrackingContext,
698 dmbProvider,
699 assemblyInformationProvider.Version,
700 instance.Name!,
701 securityLevel,
702 visibility,
703 serverPortProvider.HttpApiPort,
704 apiValidateOnly);
705
710 async ValueTask CheckPagerIsNotRunning()
711 {
712 if (!platformIdentifier.IsWindows)
713 return;
714
715 await using var otherProcess = processExecutor.GetProcessByName("byond");
716 if (otherProcess == null)
717 return;
718
719 var otherUsername = otherProcess.GetExecutingUsername();
720
721 await using var ourProcess = processExecutor.GetCurrentProcess();
722 var ourUsername = ourProcess.GetExecutingUsername();
723
724 if (otherUsername.Equals(ourUsername, StringComparison.Ordinal))
725 throw new JobException(ErrorCode.DreamDaemonPagerRunning);
726 }
727 }
728}
virtual ? long Id
The ID of the entity.
Definition EntityId.cs:14
Metadata about a server instance.
Definition Instance.cs:9
virtual ? Version DMApiVersion
The DMAPI Version.
Definition CompileJob.cs:43
DreamDaemonSecurity? MinimumSecurityLevel
The minimum DreamDaemonSecurity required to run the CompileJob's output.
Definition CompileJob.cs:35
ushort? Port
The port DreamDaemon uses. This should be publically accessible.
DreamDaemonVisibility? Visibility
The DreamDaemonVisibility level of DreamDaemon. No-op for EngineType.OpenDream.
bool? LogOutput
If process output/error text should be logged.
uint? TopicRequestTimeout
The timeout for sending and receiving BYOND topics in milliseconds.
DreamDaemonSecurity? SecurityLevel
The DreamDaemonSecurity level of DreamDaemon. No-op for EngineType.OpenDream.
Representation of the initial data passed as part of a BridgeCommandType.Startup request.
Constants used for communication with the DMAPI.
const string ParamServerPort
Identifies the Core.IServerPortProvider.HttpApiPort of the server.
const string ParamAccessIdentifier
Identifies the DMApiParameters.AccessIdentifier for the session.
const string ParamApiVersion
Identifies a DMAPI execution with the version as the value.
static readonly Version InteropVersion
The DMAPI InteropVersion being used.
Parameters necessary for duplicating a ISessionController session.
TimeSpan TopicRequestTimeout
The TimeSpan which indicates when topic requests should timeout.
void SetRuntimeInformation(RuntimeInformation runtimeInformation)
Set the RuntimeInformation post construction.
IDmbProvider Dmb
The IDmbProvider used by DreamDaemon.
readonly IEventConsumer eventConsumer
The IEventConsumer for the SessionControllerFactory.
readonly ITopicClientFactory topicClientFactory
The ITopicClientFactory for the SessionControllerFactory.
readonly IServerPortProvider serverPortProvider
The IServerPortProvider for the SessionControllerFactory.
readonly ILoggerFactory loggerFactory
The ILoggerFactory for the SessionControllerFactory.
readonly IProcessExecutor processExecutor
The IProcessExecutor for the SessionControllerFactory.
readonly IIOManager gameIOManager
The IIOManager for the Game directory.
async ValueTask CheckPagerIsNotRunning()
Make sure the BYOND pager is not running.
readonly IPlatformIdentifier platformIdentifier
The IPlatformIdentifier for the SessionControllerFactory.
async ValueTask LogDDOutput(IProcess process, string? outputFilePath, bool cliSupported, bool preserveFile, CancellationToken cancellationToken)
Attempts to log DreamDaemon output.
RuntimeInformation CreateRuntimeInformation(IDmbProvider dmbProvider, IChatTrackingContext chatTrackingContext, DreamDaemonSecurity securityLevel, DreamDaemonVisibility visibility, bool apiValidateOnly)
Create RuntimeInformation.
readonly ICryptographySuite cryptographySuite
The ICryptographySuite for the SessionControllerFactory.
async ValueTask< IProcess > CreateGameServerProcess(IDmbProvider dmbProvider, IEngineExecutableLock engineLock, DreamDaemonLaunchParameters launchParameters, string accessIdentifier, string? logFilePath, bool apiValidate, CancellationToken cancellationToken)
Creates the game server IProcess.
readonly IDreamMaker dreamMaker
The IDreamMaker for the SessionControllerFactory.
readonly IBridgeRegistrar bridgeRegistrar
The IBridgeRegistrar for the SessionControllerFactory.
async ValueTask PortBindTest(ushort port, EngineType engineType, CancellationToken cancellationToken)
Check if a given port can be bound to.
const string DreamDaemonLogsPath
Path in Diagnostics folder to DreamDaemon logs.
readonly Counter sessionsLaunched
The number of sessions launched.
readonly Api.Models.Instance instance
The Api.Models.Instance for the SessionControllerFactory.
readonly INetworkPromptReaper networkPromptReaper
The INetworkPromptReaper for the SessionControllerFactory.
SessionControllerFactory(IProcessExecutor processExecutor, IEngineManager engineManager, ITopicClientFactory topicClientFactory, ICryptographySuite cryptographySuite, IAssemblyInformationProvider assemblyInformationProvider, IIOManager gameIOManager, IIOManager diagnosticsIOManager, IChatManager chat, INetworkPromptReaper networkPromptReaper, IPlatformIdentifier platformIdentifier, IBridgeRegistrar bridgeRegistrar, IServerPortProvider serverPortProvider, IEventConsumer eventConsumer, IJobManager jobManager, IDreamMaker dreamMaker, IAsyncDelayer asyncDelayer, IDotnetDumpService dotnetDumpService, IMetricFactory metricFactory, ILoggerFactory loggerFactory, IOptionsMonitor< SessionConfiguration > sessionConfigurationOptions, ILogger< SessionControllerFactory > logger, Api.Models.Instance instance)
Initializes a new instance of the SessionControllerFactory class.
readonly ILogger< SessionControllerFactory > logger
The ILogger for the SessionControllerFactory.
readonly IChatManager chat
The IChatManager for the SessionControllerFactory.
readonly IAssemblyInformationProvider assemblyInformationProvider
The IAssemblyInformationProvider for the SessionControllerFactory.
async ValueTask< ISessionController > LaunchNew(IDmbProvider dmbProvider, IEngineExecutableLock? currentByondLock, DreamDaemonLaunchParameters launchParameters, bool apiValidate, CancellationToken cancellationToken)
Create a ISessionController from a freshly launch DreamDaemon instance.A ValueTask<TResult> resulting...
readonly IDotnetDumpService dotnetDumpService
The IDotnetDumpService for the SessionControllerFactory.
readonly IEngineManager engineManager
The IEngineManager for the SessionControllerFactory.
async ValueTask< ISessionController?> Reattach(ReattachInformation reattachInformation, CancellationToken cancellationToken)
Create a ISessionController from an existing DreamDaemon instance.A ValueTask<TResult> resulting in a...
readonly Gauge lastSessionLaunch
The time the current session was launched.
readonly IJobManager jobManager
The IJobManager for the SessionControllerFactory.
readonly IAsyncDelayer asyncDelayer
The IAsyncDelayer for the SessionControllerFactory.
readonly IOptionsMonitor< SessionConfiguration > sessionConfigurationOptions
The IOptionsMonitor<TOptions> of SessionConfiguration for the SessionControllerFactory.
readonly IIOManager diagnosticsIOManager
The IIOManager for the Diagnostics directory.
Extension methods for the Socket class.
static void BindTest(IPlatformIdentifier platformIdentifier, ushort port, bool includeIPv6, bool udp)
Attempt to exclusively bind to a given port .
Operation exceptions thrown from the context of a Models.Job.
DreamDaemonSecurity LaunchSecurityLevel
The DreamDaemonSecurity level DreamDaemon was launched with.
DreamDaemonVisibility LaunchVisibility
The DreamDaemonVisibility DreamDaemon was launched with.
For managing connected chat services.
IChatTrackingContext CreateTrackingContext()
Start tracking Commands.CustomCommands and ChannelRepresentations.
Represents a tracking of dynamic chat json files.
Provides absolute paths to the latest compiled .dmbs.
EngineVersion EngineVersion
The Api.Models.EngineVersion used to build the .dmb.
Models.CompileJob CompileJob
The CompileJob of the .dmb.
Represents usage of the two primary BYOND server executables.
string ServerExePath
The full path to the game server executable.
string FormatServerArguments(IDmbProvider dmbProvider, IReadOnlyDictionary< string, string >? parameters, DreamDaemonLaunchParameters launchParameters, string accessIdentifier, string? logFilePath)
Return the command line arguments for launching with given launchParameters .
ValueTask< Dictionary< string, string >?> LoadEnv(ILogger logger, bool forCompiler, CancellationToken cancellationToken)
Loads the environment settings for either the server or compiler.
bool PreferFileLogging
If HasStandardOutput is set, this indicates that the engine server has good file logging that should ...
bool HasStandardOutput
If ServerExePath supports being run as a command-line application and outputs log information to be c...
ValueTask< IEngineExecutableLock > UseExecutables(EngineVersion? requiredVersion, string? trustDmbFullPath, CancellationToken cancellationToken)
Lock the current installation's location and return a IEngineExecutableLock.
Consumes EventTypes and takes the appropriate actions.
ValueTask HandleEvent(EventType eventType, IEnumerable< string?> parameters, bool sensitiveParameters, bool deploymentPipeline, CancellationToken cancellationToken)
Handle a given eventType .
ITopicClient CreateTopicClient(TimeSpan timeout)
Create a ITopicClient.
Provides access to the server's HttpApiPort.
ushort HttpApiPort
The port the server listens on.
Interface for using filesystems.
Definition IIOManager.cs:14
string ResolvePath()
Retrieve the full path of the current working directory.
string ConcatPath(params string[] paths)
Combines an array of strings into a path.
Task CreateDirectory(string path, CancellationToken cancellationToken)
Create a directory at path .
Manages the runtime of Jobs.
Contains various cryptographic functions.
string GetSecureString()
Generates a 40-length secure ascii string.
Service for managing the dotnet-dump installation.
On Windows, DreamDaemon will show an unskippable prompt when using /world/proc/OpenPort()....
void RegisterProcess(IProcess process)
Register a given process for network prompt reaping.
For identifying the current platform.
bool IsWindows
If the current platform is a Windows platform.
ValueTask< IProcess > LaunchProcess(string fileName, string workingDirectory, string arguments, CancellationToken cancellationToken, IReadOnlyDictionary< string, string >? environment=null, string? fileRedirect=null, bool readStandardHandles=false, bool noShellExecute=false, bool doNotLogArguments=false)
Launch a IProcess.
IProcess? GetProcess(int id)
Get a IProcess by id .
Abstraction over a global::System.Diagnostics.Process.
Definition IProcess.cs:11
Task< string?> GetCombinedOutput(CancellationToken cancellationToken)
Get the stderr and stdout output of the IProcess.
ValueTask Delay(TimeSpan timeSpan, CancellationToken cancellationToken)
Create a Task that completes after a given timeSpan .
ErrorCode
Types of Response.ErrorMessageResponses that the API may return.
Definition ErrorCode.cs:12
DreamDaemonVisibility
The visibility setting for DreamDaemon.
DreamDaemonSecurity
DreamDaemon's security level.
EngineType
The type of engine the codebase is using.
Definition EngineType.cs:7
EventType
Types of events. Mirror in tgs.dm. Prefer last listed name for script.
Definition EventType.cs:7