tgstation-server 6.17.0
The /tg/station 13 server suite
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Static Protected Attributes | Properties | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
Tgstation.Server.Host.Components.Engine.ByondInstallerBase Class Referenceabstract

Base implementation of IEngineInstaller for EngineType.Byond. More...

Inheritance diagram for Tgstation.Server.Host.Components.Engine.ByondInstallerBase:
Inheritance graph
[legend]
Collaboration diagram for Tgstation.Server.Host.Components.Engine.ByondInstallerBase:
Collaboration graph
[legend]

Public Member Functions

override ValueTask< IEngineInstallationCreateInstallation (EngineVersion version, string path, Task installationTask, CancellationToken cancellationToken)
 Creates an IEngineInstallation for a given version .
Parameters
versionThe EngineVersion of the installation.
pathThe path to the installation.
installationTaskThe Task representing the installation process for the installation.
cancellationTokenThe CancellationToken for the operation.
Returns
A ValueTask<TResult> resulting in the IEngineInstallation.

 
override async Task CleanCache (CancellationToken cancellationToken)
 Attempts to cleans the engine's cache folder for the system.
Parameters
cancellationTokenThe CancellationToken for the operation.
Returns
A Task representing the running operation.

 
override async ValueTask< IEngineInstallationDataDownloadVersion (EngineVersion version, JobProgressReporter progressReporter, CancellationToken cancellationToken)
 Download a given engine version .
Parameters
versionThe EngineVersion of the engine to download.
jobProgressReporterThe JobProgressReporter for the operation.
cancellationTokenThe CancellationToken for the operation.
Returns
A ValueTask<TResult> resulting in the IEngineInstallationData for the download.

 
- Public Member Functions inherited from Tgstation.Server.Host.Components.Engine.EngineInstallerBase
ValueTask< IEngineInstallationCreateInstallation (EngineVersion version, string path, Task installationTask, CancellationToken cancellationToken)
 Creates an IEngineInstallation for a given version .
Parameters
versionThe EngineVersion of the installation.
pathThe path to the installation.
installationTaskThe Task representing the installation process for the installation.
cancellationTokenThe CancellationToken for the operation.
Returns
A ValueTask<TResult> resulting in the IEngineInstallation.

 
Task CleanCache (CancellationToken cancellationToken)
 Attempts to cleans the engine's cache folder for the system.
Parameters
cancellationTokenThe CancellationToken for the operation.
Returns
A Task representing the running operation.

 
ValueTask Install (EngineVersion version, string path, bool deploymentPipelineProcesses, CancellationToken cancellationToken)
 Does actions necessary to get an extracted installation working.
Parameters
versionThe EngineVersion being installed.
pathThe path to the installation.
deploymentPipelineProcessesIf the operation should consider processes it launches to be part of the deployment pipeline.
cancellationTokenThe CancellationToken for the operation.
Returns
A ValueTask representing the running operation.

 
ValueTask UpgradeInstallation (EngineVersion version, string path, CancellationToken cancellationToken)
 Does actions necessary to get upgrade a version installed by a previous version of TGS.
Parameters
versionThe EngineVersion being installed.
pathThe path to the installation.
cancellationTokenThe CancellationToken for the operation.
Returns
A ValueTask representing the running operation.

 
ValueTask< IEngineInstallationDataDownloadVersion (EngineVersion version, JobProgressReporter jobProgressReporter, CancellationToken cancellationToken)
 Download a given engine version .
Parameters
versionThe EngineVersion of the engine to download.
jobProgressReporterThe JobProgressReporter for the operation.
cancellationTokenThe CancellationToken for the operation.
Returns
A ValueTask<TResult> resulting in the IEngineInstallationData for the download.

 
ValueTask TrustDmbPath (EngineVersion version, string fullDmbPath, CancellationToken cancellationToken)
 Add a given fullDmbPath to the trusted DMBs list in BYOND's config.
Parameters
versionThe EngineVersion being used.
fullDmbPathFull path to the .dmb that should be trusted.
cancellationTokenThe CancellationToken for the operation.
Returns
A ValueTask representing the running operation.

 

Protected Member Functions

 ByondInstallerBase (IIOManager ioManager, ILogger< ByondInstallerBase > logger, IFileDownloader fileDownloader)
 Initializes a new instance of the ByondInstallerBase class.
 
string GetDreamDaemonName (Version byondVersion, out bool supportsCli)
 Get the file name of the DreamDaemon executable.
 
virtual IEnumerable< string > AdditionalCacheCleanFilePaths (string configDirectory)
 List off additional file paths in the configDirectory to delete.
 
- Protected Member Functions inherited from Tgstation.Server.Host.Components.Engine.EngineInstallerBase
 EngineInstallerBase (IIOManager ioManager, ILogger< EngineInstallerBase > logger)
 Initializes a new instance of the EngineInstallerBase class.
 
void CheckVersionValidity (EngineVersion version)
 Check that a given version is of type EngineType.Byond.
 

Static Protected Attributes

const string ByondBinPath = "byond/bin"
 The path to the BYOND bin folder.
 
const string CfgDirectoryName = "cfg"
 The path to the cfg directory.
 

Properties

override EngineType TargetEngineType [get]
 
string PathToUserFolder [get]
 Path to the system user's local BYOND folder.
 
string DreamMakerName [get]
 Path to the DreamMaker executable.
 
string ByondRevisionsUrlTemplate [get]
 Gets the URL formatter string for downloading a byond version of {0:Major} {1:Minor}.
 
- Properties inherited from Tgstation.Server.Host.Components.Engine.EngineInstallerBase
EngineType TargetEngineType [get]
 The EngineType the installer supports.
 
IIOManager IOManager [get]
 Gets the IIOManager for the EngineInstallerBase.
 
ILogger< EngineInstallerBaseLogger [get]
 Gets the ILogger for the EngineInstallerBase.
 

Private Member Functions

Uri GetDownloadZipUrl (EngineVersion version)
 Create a Uri pointing to the location of the download for a given version .
 

Private Attributes

readonly IFileDownloader fileDownloader
 The IFileDownloader for the ByondInstallerBase.
 

Static Private Attributes

const string CacheDirectoryName = "cache"
 The name of BYOND's cache directory.
 
static readonly Version MapThreadsVersion = new(515, 1609)
 The first Version of BYOND that supports the '-map-threads' parameter on DreamDaemon.
 

Detailed Description

Base implementation of IEngineInstaller for EngineType.Byond.

Definition at line 19 of file ByondInstallerBase.cs.

Constructor & Destructor Documentation

◆ ByondInstallerBase()

Tgstation.Server.Host.Components.Engine.ByondInstallerBase.ByondInstallerBase ( IIOManager  ioManager,
ILogger< ByondInstallerBase logger,
IFileDownloader  fileDownloader 
)
protected

Initializes a new instance of the ByondInstallerBase class.

Parameters
ioManagerThe IIOManager for the EngineInstallerBase.
loggerThe ILogger for the EngineInstallerBase.
fileDownloaderThe value of fileDownloader.

Definition at line 70 of file ByondInstallerBase.cs.

71 : base(ioManager, logger)
72 {
73 this.fileDownloader = fileDownloader ?? throw new ArgumentNullException(nameof(fileDownloader));
74 }
readonly IFileDownloader fileDownloader
The IFileDownloader for the ByondInstallerBase.

References Tgstation.Server.Host.Components.Engine.ByondInstallerBase.fileDownloader.

Member Function Documentation

◆ AdditionalCacheCleanFilePaths()

virtual IEnumerable< string > Tgstation.Server.Host.Components.Engine.ByondInstallerBase.AdditionalCacheCleanFilePaths ( string  configDirectory)
protectedvirtual

List off additional file paths in the configDirectory to delete.

Parameters
configDirectoryThe full path to the relevant CfgDirectoryName.
Returns
An IEnumerable<T> of paths in configDirectory to clean.

Reimplemented in Tgstation.Server.Host.Components.Engine.WindowsByondInstaller.

Referenced by Tgstation.Server.Host.Components.Engine.ByondInstallerBase.CleanCache().

Here is the caller graph for this function:

◆ CleanCache()

override async Task Tgstation.Server.Host.Components.Engine.ByondInstallerBase.CleanCache ( CancellationToken  cancellationToken)

Attempts to cleans the engine's cache folder for the system.

Parameters
cancellationTokenThe CancellationToken for the operation.
Returns
A Task representing the running operation.

Implements Tgstation.Server.Host.Components.Engine.IEngineInstaller.

Definition at line 104 of file ByondInstallerBase.cs.

105 {
106 try
107 {
108 var byondDir = PathToUserFolder;
109
110 Logger.LogDebug("Cleaning BYOND cache...");
111 async Task CleanDirectorySafe()
112 {
113 try
114 {
117 byondDir,
119 cancellationToken);
120 }
121 catch (Exception ex)
122 {
123 Logger.LogWarning(ex, "Failed to clean BYOND cache!");
124 }
125 }
126
127 var cacheCleanTask = CleanDirectorySafe();
128
129 // Create local cfg directory in case it doesn't exist
130 var localCfgDirectory = IOManager.ConcatPath(
131 byondDir,
133
134 var cfgCreateTask = IOManager.CreateDirectory(
135 localCfgDirectory,
136 cancellationToken);
137
138 var additionalCleanTasks = AdditionalCacheCleanFilePaths(localCfgDirectory)
139 .Select(path => IOManager.DeleteFile(path, cancellationToken));
140
141 await Task.WhenAll(cacheCleanTask, cfgCreateTask, Task.WhenAll(additionalCleanTasks));
142 }
143 catch (Exception ex) when (ex is not OperationCanceledException)
144 {
145 Logger.LogWarning(ex, "Error cleaning BYOND cache!");
146 }
147 }
const string CacheDirectoryName
The name of BYOND's cache directory.
const string CfgDirectoryName
The path to the cfg directory.
virtual IEnumerable< string > AdditionalCacheCleanFilePaths(string configDirectory)
List off additional file paths in the configDirectory to delete.
string PathToUserFolder
Path to the system user's local BYOND folder.
IIOManager IOManager
Gets the IIOManager for the EngineInstallerBase.
ILogger< EngineInstallerBase > Logger
Gets the ILogger for the EngineInstallerBase.
string ConcatPath(params string[] paths)
Combines an array of strings into a path.
Task CreateDirectory(string path, CancellationToken cancellationToken)
Create a directory at path .
Task DeleteFile(string path, CancellationToken cancellationToken)
Deletes a file at path .
Task DeleteDirectory(string path, CancellationToken cancellationToken)
Recursively delete a directory, removes and does not enter any symlinks encounterd.

References Tgstation.Server.Host.Components.Engine.ByondInstallerBase.AdditionalCacheCleanFilePaths(), Tgstation.Server.Host.Components.Engine.ByondInstallerBase.CacheDirectoryName, Tgstation.Server.Host.Components.Engine.ByondInstallerBase.CfgDirectoryName, Tgstation.Server.Host.IO.IIOManager.ConcatPath(), Tgstation.Server.Host.IO.IIOManager.CreateDirectory(), Tgstation.Server.Host.IO.IIOManager.DeleteDirectory(), Tgstation.Server.Host.IO.IIOManager.DeleteFile(), Tgstation.Server.Host.Components.Engine.EngineInstallerBase.IOManager, Tgstation.Server.Host.Components.Engine.EngineInstallerBase.Logger, and Tgstation.Server.Host.Components.Engine.ByondInstallerBase.PathToUserFolder.

Here is the call graph for this function:

◆ CreateInstallation()

override ValueTask< IEngineInstallation > Tgstation.Server.Host.Components.Engine.ByondInstallerBase.CreateInstallation ( EngineVersion  version,
string  path,
Task  installationTask,
CancellationToken  cancellationToken 
)

Creates an IEngineInstallation for a given version .

Parameters
versionThe EngineVersion of the installation.
pathThe path to the installation.
installationTaskThe Task representing the installation process for the installation.
cancellationTokenThe CancellationToken for the operation.
Returns
A ValueTask<TResult> resulting in the IEngineInstallation.

Implements Tgstation.Server.Host.Components.Engine.IEngineInstaller.

Definition at line 77 of file ByondInstallerBase.cs.

78 {
79 CheckVersionValidity(version);
80
81 var installationIOManager = new ResolvingIOManager(IOManager, path);
82 var supportsMapThreads = version.Version >= MapThreadsVersion;
83
84 return ValueTask.FromResult<IEngineInstallation>(
85 new ByondInstallation(
86 installationIOManager,
87 installationTask,
88 version,
89 installationIOManager.ResolvePath(
90 installationIOManager.ConcatPath(
93 version.Version!,
94 out var supportsCli))),
95 installationIOManager.ResolvePath(
96 installationIOManager.ConcatPath(
99 supportsCli,
100 supportsMapThreads));
101 }
Version? Version
The System.Version of the engine. Currently only valid when Engine is EngineType.Byond.
string GetDreamDaemonName(Version byondVersion, out bool supportsCli)
Get the file name of the DreamDaemon executable.
static readonly Version MapThreadsVersion
The first Version of BYOND that supports the '-map-threads' parameter on DreamDaemon.
const string ByondBinPath
The path to the BYOND bin folder.
string DreamMakerName
Path to the DreamMaker executable.
void CheckVersionValidity(EngineVersion version)
Check that a given version is of type EngineType.Byond.
An IIOManager that resolve relative paths from another IIOManager to a subdirectory of that.

References Tgstation.Server.Host.Components.Engine.ByondInstallerBase.ByondBinPath, Tgstation.Server.Host.Components.Engine.EngineInstallerBase.CheckVersionValidity(), Tgstation.Server.Host.Components.Engine.ByondInstallerBase.DreamMakerName, Tgstation.Server.Host.Components.Engine.ByondInstallerBase.GetDreamDaemonName(), Tgstation.Server.Host.Components.Engine.EngineInstallerBase.IOManager, Tgstation.Server.Host.Components.Engine.ByondInstallerBase.MapThreadsVersion, and Tgstation.Server.Api.Models.EngineVersion.Version.

Here is the call graph for this function:

◆ DownloadVersion()

override async ValueTask< IEngineInstallationData > Tgstation.Server.Host.Components.Engine.ByondInstallerBase.DownloadVersion ( EngineVersion  version,
JobProgressReporter  progressReporter,
CancellationToken  cancellationToken 
)

Download a given engine version .

Parameters
versionThe EngineVersion of the engine to download.
jobProgressReporterThe JobProgressReporter for the operation.
cancellationTokenThe CancellationToken for the operation.
Returns
A ValueTask<TResult> resulting in the IEngineInstallationData for the download.

Implements Tgstation.Server.Host.Components.Engine.IEngineInstaller.

Definition at line 150 of file ByondInstallerBase.cs.

151 {
152 CheckVersionValidity(version);
153
154 var url = GetDownloadZipUrl(version);
155 Logger.LogTrace("Downloading {engineType} version {version} from {url}...", TargetEngineType, version, url);
156
157 await using var download = fileDownloader.DownloadFile(url, null);
158 await using var buffer = new BufferedFileStreamProvider(
159 await download.GetResult(cancellationToken));
160
161 var stream = await buffer.GetOwnedResult(cancellationToken);
162 try
163 {
164 return new ZipStreamEngineInstallationData(
165 IOManager,
166 stream);
167 }
168 catch
169 {
170 await stream.DisposeAsync();
171 throw;
172 }
173 }
Uri GetDownloadZipUrl(EngineVersion version)
Create a Uri pointing to the location of the download for a given version .
IFileStreamProvider that provides a ISeekableFileStreamProvider from an input Stream.
IFileStreamProvider DownloadFile(Uri url, string? bearerToken)
Downloads a file from a given url .

References Tgstation.Server.Host.Components.Engine.EngineInstallerBase.CheckVersionValidity(), Tgstation.Server.Host.IO.IFileDownloader.DownloadFile(), Tgstation.Server.Host.Components.Engine.ByondInstallerBase.fileDownloader, Tgstation.Server.Host.Components.Engine.ByondInstallerBase.GetDownloadZipUrl(), Tgstation.Server.Host.Components.Engine.EngineInstallerBase.IOManager, Tgstation.Server.Host.Components.Engine.EngineInstallerBase.Logger, and Tgstation.Server.Host.Components.Engine.ByondInstallerBase.TargetEngineType.

Here is the call graph for this function:

◆ GetDownloadZipUrl()

Uri Tgstation.Server.Host.Components.Engine.ByondInstallerBase.GetDownloadZipUrl ( EngineVersion  version)
private

Create a Uri pointing to the location of the download for a given version .

Parameters
versionThe EngineVersion to create a Uri for.
Returns
A Uri pointing to the version download location.

Definition at line 195 of file ByondInstallerBase.cs.

196 {
197 CheckVersionValidity(version);
198 var url = String.Format(CultureInfo.InvariantCulture, ByondRevisionsUrlTemplate, version.Version!.Major, version.Version.Minor);
199 return new Uri(url);
200 }
string ByondRevisionsUrlTemplate
Gets the URL formatter string for downloading a byond version of {0:Major} {1:Minor}.

References Tgstation.Server.Host.Components.Engine.ByondInstallerBase.ByondRevisionsUrlTemplate, Tgstation.Server.Host.Components.Engine.EngineInstallerBase.CheckVersionValidity(), and Tgstation.Server.Api.Models.EngineVersion.Version.

Referenced by Tgstation.Server.Host.Components.Engine.ByondInstallerBase.DownloadVersion().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetDreamDaemonName()

string Tgstation.Server.Host.Components.Engine.ByondInstallerBase.GetDreamDaemonName ( Version  byondVersion,
out bool  supportsCli 
)
abstractprotected

Get the file name of the DreamDaemon executable.

Parameters
byondVersionThe Version of BYOND to select the executable name for.
supportsCliWhether or not the returned path supports being run as a command-line application.
Returns
The file name of the DreamDaemon executable.

Referenced by Tgstation.Server.Host.Components.Engine.ByondInstallerBase.CreateInstallation().

Here is the caller graph for this function:

Member Data Documentation

◆ ByondBinPath

const string Tgstation.Server.Host.Components.Engine.ByondInstallerBase.ByondBinPath = "byond/bin"
staticprotected

◆ CacheDirectoryName

const string Tgstation.Server.Host.Components.Engine.ByondInstallerBase.CacheDirectoryName = "cache"
staticprivate

The name of BYOND's cache directory.

Definition at line 34 of file ByondInstallerBase.cs.

Referenced by Tgstation.Server.Host.Components.Engine.ByondInstallerBase.CleanCache().

◆ CfgDirectoryName

const string Tgstation.Server.Host.Components.Engine.ByondInstallerBase.CfgDirectoryName = "cfg"
staticprotected

◆ fileDownloader

readonly IFileDownloader Tgstation.Server.Host.Components.Engine.ByondInstallerBase.fileDownloader
private

◆ MapThreadsVersion

readonly Version Tgstation.Server.Host.Components.Engine.ByondInstallerBase.MapThreadsVersion = new(515, 1609)
staticprivate

The first Version of BYOND that supports the '-map-threads' parameter on DreamDaemon.

Definition at line 39 of file ByondInstallerBase.cs.

Referenced by Tgstation.Server.Host.Components.Engine.ByondInstallerBase.CreateInstallation().

Property Documentation

◆ ByondRevisionsUrlTemplate

string Tgstation.Server.Host.Components.Engine.ByondInstallerBase.ByondRevisionsUrlTemplate
getabstractprotected

Gets the URL formatter string for downloading a byond version of {0:Major} {1:Minor}.

Definition at line 57 of file ByondInstallerBase.cs.

57{ get; }

Referenced by Tgstation.Server.Host.Components.Engine.ByondInstallerBase.GetDownloadZipUrl().

◆ DreamMakerName

string Tgstation.Server.Host.Components.Engine.ByondInstallerBase.DreamMakerName
getabstractprotected

Path to the DreamMaker executable.

Definition at line 52 of file ByondInstallerBase.cs.

52{ get; }

Referenced by Tgstation.Server.Host.Components.Engine.ByondInstallerBase.CreateInstallation().

◆ PathToUserFolder

string Tgstation.Server.Host.Components.Engine.ByondInstallerBase.PathToUserFolder
getabstractprotected

Path to the system user's local BYOND folder.

Definition at line 47 of file ByondInstallerBase.cs.

47{ get; }

Referenced by Tgstation.Server.Host.Components.Engine.ByondInstallerBase.CleanCache().

◆ TargetEngineType

override EngineType Tgstation.Server.Host.Components.Engine.ByondInstallerBase.TargetEngineType
getprotected

The documentation for this class was generated from the following file: