diff --git a/src/Tgstation.Server.Host/Components/Compiler/DmbFactory.cs b/src/Tgstation.Server.Host/Components/Compiler/DmbFactory.cs
index c22217328c..3a30381407 100644
--- a/src/Tgstation.Server.Host/Components/Compiler/DmbFactory.cs
+++ b/src/Tgstation.Server.Host/Components/Compiler/DmbFactory.cs
@@ -33,10 +33,12 @@ namespace Tgstation.Server.Host.Components.Compiler
/// The for the
///
readonly IDatabaseContextFactory databaseContextFactory;
+
///
/// The for the
///
readonly IIOManager ioManager;
+
///
/// The for the
///
@@ -46,6 +48,7 @@ namespace Tgstation.Server.Host.Components.Compiler
/// The for the
///
readonly Api.Models.Instance instance;
+
///
/// The for
///
@@ -55,10 +58,12 @@ namespace Tgstation.Server.Host.Components.Compiler
/// representing calls to
///
Task cleanupTask;
+
///
/// resulting in the latest yet to exist
///
TaskCompletionSource newerDmbTcs;
+
///
/// The latest
///
@@ -87,7 +92,7 @@ namespace Tgstation.Server.Host.Components.Compiler
}
///
- public void Dispose() => cleanupCts.Dispose(); //we don't dispose nextDmbProvider here, since it might be the only thing we have
+ public void Dispose() => cleanupCts.Dispose(); // we don't dispose nextDmbProvider here, since it might be the only thing we have
///
/// Delete the of
@@ -99,12 +104,13 @@ namespace Tgstation.Server.Host.Components.Compiler
{
var deleteJob = ioManager.DeleteDirectory(job.DirectoryName.ToString(), cleanupCts.Token);
Task otherTask;
- //lock (this) //already locked below
+
+ // lock (this) //already locked below
otherTask = cleanupTask;
await Task.WhenAll(otherTask, deleteJob).ConfigureAwait(false);
}
+
lock (this)
- {
if (!jobLockCounts.TryGetValue(job.Id, out var currentVal) || currentVal == 1)
{
jobLockCounts.Remove(job.Id);
@@ -116,7 +122,6 @@ namespace Tgstation.Server.Host.Components.Compiler
var decremented = --jobLockCounts[job.Id];
logger.LogTrace("Compile job {0} lock count now: {1}", job.Id, decremented);
}
- }
}
///
@@ -156,13 +161,14 @@ namespace Tgstation.Server.Host.Components.Compiler
///
public Task StartAsync(CancellationToken cancellationToken) => databaseContextFactory.UseContext(async (db) =>
{
- //where complete clause not necessary, only successful COMPILEjobs get in the db
+ // where complete clause not necessary, only successful COMPILEjobs get in the db
var cj = await db.CompileJobs.Where(x => x.Job.Instance.Id == instance.Id)
.OrderByDescending(x => x.Job.StoppedAt).FirstOrDefaultAsync(cancellationToken).ConfigureAwait(false);
if (cj == default(CompileJob))
return;
await LoadCompileJob(cj, cancellationToken).ConfigureAwait(false);
- //we dont do CleanUnusedCompileJobs here because the watchdog may have plans for them yet
+
+ // we dont do CleanUnusedCompileJobs here because the watchdog may have plans for them yet
});
///
@@ -178,12 +184,12 @@ namespace Tgstation.Server.Host.Components.Compiler
if (compileJob == null)
throw new ArgumentNullException(nameof(compileJob));
- //ensure we have the entire compile job tree
+ // ensure we have the entire compile job tree
await databaseContextFactory.UseContext(async db => compileJob = await db.CompileJobs.Where(x => x.Id == compileJob.Id)
.Include(x => x.Job).ThenInclude(x => x.StartedBy)
.Include(x => x.RevisionInformation).ThenInclude(x => x.PrimaryTestMerge).ThenInclude(x => x.MergedBy)
.Include(x => x.RevisionInformation).ThenInclude(x => x.ActiveTestMerges).ThenInclude(x => x.TestMerge).ThenInclude(x => x.MergedBy)
- .FirstAsync(cancellationToken).ConfigureAwait(false)).ConfigureAwait(false); //can't wait to see that query
+ .FirstAsync(cancellationToken).ConfigureAwait(false)).ConfigureAwait(false); // can't wait to see that query
logger.LogTrace("Loading compile job {0}...", compileJob.Id);
var providerSubmitted = false;
@@ -201,7 +207,7 @@ namespace Tgstation.Server.Host.Components.Compiler
if (!(await primaryCheckTask.ConfigureAwait(false) && await secondaryCheckTask.ConfigureAwait(false)))
{
logger.LogWarning("Error loading compile job, .dmb missing!");
- return null; //omae wa mou shinderu
+ return null; // omae wa mou shinderu
}
lock (this)
@@ -231,23 +237,24 @@ namespace Tgstation.Server.Host.Components.Compiler
public async Task CleanUnusedCompileJobs(CompileJob exceptThisOne, CancellationToken cancellationToken)
{
List jobIdsToSkip;
- //don't clean locked directories
+
+ // don't clean locked directories
lock (this)
jobIdsToSkip = jobLockCounts.Select(x => x.Key).ToList();
List jobUidsToNotErase = null;
- //find the uids of locked directories
+ // find the uids of locked directories
await databaseContextFactory.UseContext(async db =>
{
jobUidsToNotErase = await db.CompileJobs.Where(x => x.Job.Instance.Id == instance.Id && jobIdsToSkip.Contains(x.Id)).Select(x => x.DirectoryName.Value.ToString().ToUpperInvariant()).ToListAsync(cancellationToken).ConfigureAwait(false);
}).ConfigureAwait(false);
- //add the other exemption
+ // add the other exemption
if (exceptThisOne != null)
jobUidsToNotErase.Add(exceptThisOne.DirectoryName.Value.ToString().ToUpperInvariant());
- //cleanup
+ // cleanup
await ioManager.CreateDirectory(".", cancellationToken).ConfigureAwait(false);
var directories = await ioManager.GetDirectories(".", cancellationToken).ConfigureAwait(false);
int deleting = 0;
diff --git a/src/Tgstation.Server.Host/Components/Compiler/DmbProvider.cs b/src/Tgstation.Server.Host/Components/Compiler/DmbProvider.cs
index bf042d1912..31cbba7d18 100644
--- a/src/Tgstation.Server.Host/Components/Compiler/DmbProvider.cs
+++ b/src/Tgstation.Server.Host/Components/Compiler/DmbProvider.cs
@@ -28,6 +28,7 @@ namespace Tgstation.Server.Host.Components.Compiler
/// The for the
///
readonly IIOManager ioManager;
+
///
/// The to run when is called
///
diff --git a/src/Tgstation.Server.Host/Components/Compiler/DreamMaker.cs b/src/Tgstation.Server.Host/Components/Compiler/DreamMaker.cs
index 117edf4b3d..7bed49fdc8 100644
--- a/src/Tgstation.Server.Host/Components/Compiler/DreamMaker.cs
+++ b/src/Tgstation.Server.Host/Components/Compiler/DreamMaker.cs
@@ -24,14 +24,17 @@ namespace Tgstation.Server.Host.Components.Compiler
/// Name of the primary directory used for compilation
///
public const string ADirectoryName = "A";
+
///
/// Name of the secondary directory used for compilation
///
public const string BDirectoryName = "B";
+
///
/// Extension for .dmbs
///
public const string DmbExtension = ".dmb";
+
///
/// Extension for .dmes
///
@@ -41,42 +44,52 @@ namespace Tgstation.Server.Host.Components.Compiler
/// The for
///
readonly IByondManager byond;
+
///
/// The for
///
readonly IIOManager ioManager;
+
///
/// The for
///
readonly StaticFiles.IConfiguration configuration;
+
///
/// The for
///
readonly ISessionControllerFactory sessionControllerFactory;
+
///
/// The for
///
readonly ICompileJobConsumer compileJobConsumer;
+
///
/// The for
///
readonly IApplication application;
+
///
/// The for
///
readonly IEventConsumer eventConsumer;
+
///
/// The for
///
readonly IChat chat;
+
///
/// The for
///
readonly IProcessExecutor processExecutor;
+
///
/// The for
///
readonly IWatchdog watchdog;
+
///
/// The for
///
@@ -133,13 +146,13 @@ namespace Tgstation.Server.Host.Components.Compiler
{
AllowWebClient = false,
PrimaryPort = portToUse,
- SecurityLevel = securityLevel, //all it needs to read the file and exit
+ SecurityLevel = securityLevel,
StartupTimeout = timeout
};
var dirA = ioManager.ConcatPath(job.DirectoryName.ToString(), ADirectoryName);
- job.MinimumSecurityLevel = securityLevel; //needed for the TempDmbProvider
+ job.MinimumSecurityLevel = securityLevel; // needed for the TempDmbProvider
var provider = new TemporaryDmbProvider(ioManager.ResolvePath(dirA), String.Concat(job.DmeName, DmbExtension), job);
var timeoutAt = DateTimeOffset.Now.AddSeconds(timeout);
@@ -184,13 +197,13 @@ namespace Tgstation.Server.Host.Components.Compiler
throw new InvalidOperationException(String.Format(CultureInfo.InvariantCulture, "Session controller returned unexpected ApiValidationStatus: {0}", validationStatus));
}
}
-
+
throw new JobException("DMAPI validation timed out!");
}
}
///
- /// Compiles a .dme with DreamMaker
+ /// Compiles a .dme with DreamMaker
///
/// The path to the DreamMaker executable
/// The for the operation
@@ -327,8 +340,6 @@ namespace Tgstation.Server.Host.Components.Compiler
var progressTask = ProgressTask();
try
{
-
-
var commitInsert = revisionInformation.CommitSha.Substring(0, 7);
string remoteCommitInsert;
if (revisionInformation.CommitSha == revisionInformation.OriginCommitSha)
@@ -366,7 +377,7 @@ namespace Tgstation.Server.Host.Components.Compiler
}
await chatTask.ConfigureAwait(false);
- };
+ }
try
{
@@ -375,18 +386,18 @@ namespace Tgstation.Server.Host.Components.Compiler
var dirA = ioManager.ConcatPath(job.DirectoryName.ToString(), ADirectoryName);
var dirB = ioManager.ConcatPath(job.DirectoryName.ToString(), BDirectoryName);
+ // copy the repository
logger.LogTrace("Copying repository to game directory...");
- //copy the repository
var fullDirA = ioManager.ResolvePath(dirA);
var repoOrigin = repository.Origin;
using (repository)
await repository.CopyTo(fullDirA, cancellationToken).ConfigureAwait(false);
- //run precompile scripts
+ // run precompile scripts
var resolvedGameDirectory = ioManager.ResolvePath(ioManager.ConcatPath(job.DirectoryName.ToString(), ADirectoryName));
await eventConsumer.HandleEvent(EventType.CompileStart, new List { resolvedGameDirectory, repoOrigin }, cancellationToken).ConfigureAwait(false);
- //determine the dme
+ // determine the dme
if (job.DmeName == null)
{
logger.LogTrace("Searching for available .dmes...");
@@ -403,11 +414,12 @@ namespace Tgstation.Server.Host.Components.Compiler
await ModifyDme(job, cancellationToken).ConfigureAwait(false);
- //run compiler, verify api
+ // run compiler
job.ByondVersion = byondLock.Version.ToString();
var exitCode = await RunDreamMaker(byondLock.DreamMakerPath, job, cancellationToken).ConfigureAwait(false);
+ // verify api
try
{
if (exitCode != 0)
@@ -417,7 +429,7 @@ namespace Tgstation.Server.Host.Components.Compiler
}
catch (JobException)
{
- //server never validated or compile failed
+ // DD never validated or compile failed
await eventConsumer.HandleEvent(EventType.CompileFailure, new List { resolvedGameDirectory, exitCode == 0 ? "1" : "0" }, cancellationToken).ConfigureAwait(false);
throw;
}
@@ -427,12 +439,12 @@ namespace Tgstation.Server.Host.Components.Compiler
logger.LogTrace("Duplicating compiled game...");
- //duplicate the dmb et al
+ // duplicate the dmb et al
await ioManager.CopyDirectory(dirA, dirB, null, cancellationToken).ConfigureAwait(false);
logger.LogTrace("Applying static game file symlinks...");
- //symlink in the static data
+ // symlink in the static data
var symATask = configuration.SymlinkStaticFilesTo(fullDirA, cancellationToken);
var symBTask = configuration.SymlinkStaticFilesTo(ioManager.ResolvePath(dirB), cancellationToken);