2using System.Collections.Generic;
6using System.Threading.Tasks;
11using Microsoft.Extensions.Logging;
28 public abstract string ServerExePath {
get; }
31 public abstract string CompilerExePath {
get; }
34 public abstract bool HasStandardOutput {
get; }
37 public abstract bool PreferFileLogging {
get; }
40 public abstract bool PromptsForNetworkAccess {
get; }
43 public abstract bool UseDotnetDump {
get; }
46 public abstract Task InstallationTask {
get; }
51 protected IIOManager InstallationIOManager {
get; }
59 protected static string EncodeParameters(
60 IReadOnlyDictionary<string, string>? parameters,
63 var parametersString = parameters !=
null
64 ? $
"{String.Join('&', parameters.Select(kvp => $"{HttpUtility.UrlEncode(kvp.Key)}={HttpUtility.UrlEncode(kvp.Value)}
"))}&"
70 return parametersString;
79 InstallationIOManager = installationIOManager ??
throw new ArgumentNullException(nameof(installationIOManager));
83 public abstract string FormatCompilerArguments(
string dmePath,
string? additionalArguments);
86 public abstract string FormatServerArguments(
88 IReadOnlyDictionary<string, string>? parameters,
90 string accessIdentifier,
94 public virtual async ValueTask
StopServerProcess(ILogger logger,
IProcess process,
string accessIdentifier, ushort port, CancellationToken cancellationToken)
96 ArgumentNullException.ThrowIfNull(logger);
97 cancellationToken.ThrowIfCancellationRequested();
98 logger.LogTrace(
"Terminating engine server process...");
104 public async ValueTask<Dictionary<string, string>?> LoadEnv(ILogger logger,
bool forCompiler, CancellationToken cancellationToken)
106 ArgumentNullException.ThrowIfNull(logger);
108 var envFile = forCompiler
112 if (!await InstallationIOManager.FileExists(envFile, cancellationToken))
114 logger.LogTrace(
"No {envFile} present in engine installation {version}", envFile, Version);
118 logger.LogDebug(
"Loading {envFile} for engine installation {version}...", envFile, Version);
120 var fileBytes = await InstallationIOManager.ReadAllBytes(envFile, cancellationToken);
121 var fileContents = Encoding.UTF8.GetString(fileBytes);
122 var parser =
new EnvParser();
126 var variables = parser.Parse(fileContents);
128 return variables.ToDictionary();
132 logger.LogWarning(ex,
"Unable to parse {envFile}!", envFile);
Information about an engine installation.
Launch settings for DreamDaemon.
string? AdditionalParameters
Parameters string for DreamDaemon.
Provides absolute paths to the latest compiled .dmbs.
Interface for using filesystems.
Task< int?> Lifetime
The Task<TResult> resulting in the exit code of the process or null if the process was detached.
Abstraction over a global::System.Diagnostics.Process.
void Terminate()
Asycnhronously terminates the process.
await base. StopServerProcess(logger, process, accessIdentifier, port, cancellationToken)