mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-30 16:39:21 +01:00
More test fixes
This commit is contained in:
@@ -455,13 +455,20 @@ namespace Tgstation.Server.Host.Components
|
||||
/// <inheritdoc />
|
||||
public async Task StopAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
await jobManager.StopAsync(cancellationToken).ConfigureAwait(false);
|
||||
await Task.WhenAll(instances.Select(x => x.Value.Instance.StopAsync(cancellationToken))).ConfigureAwait(false);
|
||||
await instanceFactory.StopAsync(cancellationToken).ConfigureAwait(false);
|
||||
try
|
||||
{
|
||||
await jobManager.StopAsync(cancellationToken).ConfigureAwait(false);
|
||||
await Task.WhenAll(instances.Select(x => x.Value.Instance.StopAsync(cancellationToken))).ConfigureAwait(false);
|
||||
await instanceFactory.StopAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
// downgrade the db if necessary
|
||||
if (downgradeVersion != null)
|
||||
await databaseContextFactory.UseContext(db => databaseSeeder.Downgrade(db, downgradeVersion, cancellationToken)).ConfigureAwait(false);
|
||||
// downgrade the db if necessary
|
||||
if (downgradeVersion != null)
|
||||
await databaseContextFactory.UseContext(db => databaseSeeder.Downgrade(db, downgradeVersion, cancellationToken)).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogError("Instance manager stop exception: {0}", ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -38,11 +38,6 @@ namespace Tgstation.Server.Host.Components.Session
|
||||
/// </summary>
|
||||
CompileJob CompileJob { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The current port DreamDaemon is listening on
|
||||
/// </summary>
|
||||
ushort? Port { get; }
|
||||
|
||||
/// <summary>
|
||||
/// If the port should be rotated off when the world reboots
|
||||
/// </summary>
|
||||
|
||||
@@ -42,26 +42,7 @@ namespace Tgstation.Server.Host.Components.Session
|
||||
public Models.CompileJob CompileJob => reattachInformation.Dmb.CompileJob;
|
||||
|
||||
/// <inheritdoc />
|
||||
public ushort? Port
|
||||
{
|
||||
get
|
||||
{
|
||||
CheckDisposed();
|
||||
if (portClosedForReboot)
|
||||
return null;
|
||||
return reattachInformation.Port;
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public RebootState RebootState
|
||||
{
|
||||
get
|
||||
{
|
||||
CheckDisposed();
|
||||
return reattachInformation.RebootState;
|
||||
}
|
||||
}
|
||||
public RebootState RebootState => reattachInformation.RebootState;
|
||||
|
||||
/// <inheritdoc />
|
||||
public Version DMApiVersion { get; private set; }
|
||||
@@ -262,7 +243,10 @@ namespace Tgstation.Server.Host.Components.Session
|
||||
startupTimeout,
|
||||
reattached);
|
||||
|
||||
logger.LogDebug("Created session controller. CommsKey: {0}, Port: {1}", reattachInformation.AccessIdentifier, Port);
|
||||
logger.LogDebug(
|
||||
"Created session controller. CommsKey: {0}, Port: {1}",
|
||||
reattachInformation.AccessIdentifier,
|
||||
reattachInformation.Port);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
@@ -463,7 +463,20 @@ namespace Tgstation.Server.Host.Components.StaticFiles
|
||||
var files = await ioManager.GetFilesWithExtension(EventScriptsSubdirectory, platformIdentifier.ScriptFileExtension, false, cancellationToken).ConfigureAwait(false);
|
||||
var resolvedScriptsDir = ioManager.ResolvePath(EventScriptsSubdirectory);
|
||||
|
||||
foreach (var I in files.Select(x => ioManager.GetFileName(x)).Where(x => x.StartsWith(scriptName, StringComparison.Ordinal)))
|
||||
var scriptFiles = files
|
||||
.Select(x => ioManager.GetFileName(x))
|
||||
.Where(x => x.StartsWith(scriptName, StringComparison.Ordinal))
|
||||
.ToList();
|
||||
|
||||
if (!scriptFiles.Any())
|
||||
{
|
||||
logger.LogTrace("No event scripts starting with \"{0}\" detected", scriptName);
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var I in scriptFiles)
|
||||
{
|
||||
logger.LogTrace("Running event script {0}...", I);
|
||||
using (var script = processExecutor.LaunchProcess(
|
||||
ioManager.ConcatPath(resolvedScriptsDir, I),
|
||||
resolvedScriptsDir,
|
||||
@@ -481,6 +494,7 @@ namespace Tgstation.Server.Host.Components.StaticFiles
|
||||
else
|
||||
logger.LogDebug("Script output:{0}{1}", Environment.NewLine, scriptOutput);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Tgstation.Server.Host.Configuration;
|
||||
|
||||
@@ -15,17 +15,20 @@ namespace Tgstation.Server.Host.Database.Design
|
||||
/// <typeparam name="TDatabaseContext">The <see cref="DatabaseContext"/> to create <see cref="DbContextOptions"/> for.</typeparam>
|
||||
/// <param name="databaseType">The <see cref="DatabaseConfiguration.DatabaseType"/>.</param>
|
||||
/// <param name="connectionString">The <see cref="DatabaseConfiguration.ConnectionString"/>.</param>
|
||||
/// <param name="serverVersion">The <see cref="DatabaseConfiguration.ServerVersion"/>.</param>
|
||||
/// <returns>The <see cref="IOptions{TOptions}"/> for the <see cref="DatabaseConfiguration"/></returns>
|
||||
public static DbContextOptions<TDatabaseContext> CreateDatabaseContextOptions<TDatabaseContext>(
|
||||
DatabaseType databaseType,
|
||||
string connectionString)
|
||||
string connectionString,
|
||||
string serverVersion = null)
|
||||
where TDatabaseContext : DatabaseContext
|
||||
{
|
||||
var dbConfig = new DatabaseConfiguration
|
||||
{
|
||||
DesignTime = true,
|
||||
DatabaseType = databaseType,
|
||||
ConnectionString = connectionString
|
||||
ConnectionString = connectionString,
|
||||
ServerVersion = serverVersion
|
||||
};
|
||||
|
||||
var optionsFac = new DbContextOptionsBuilder<TDatabaseContext>();
|
||||
|
||||
+4
-5
@@ -1,4 +1,4 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using System;
|
||||
|
||||
namespace Tgstation.Server.Host.Database.Migrations
|
||||
@@ -39,19 +39,18 @@ namespace Tgstation.Server.Host.Database.Migrations
|
||||
name: "LaunchSecurityLevel",
|
||||
table: "ReattachInformations");
|
||||
|
||||
// No default values b/c lol mysql
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "ChatChannelsJson",
|
||||
table: "ReattachInformations",
|
||||
type: "longtext CHARACTER SET utf8mb4",
|
||||
nullable: false,
|
||||
defaultValue: "chat_channels.tgs.json");
|
||||
nullable: false);
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "ChatCommandsJson",
|
||||
table: "ReattachInformations",
|
||||
type: "longtext CHARACTER SET utf8mb4",
|
||||
nullable: false,
|
||||
defaultValue: "chat_commands.tgs.json");
|
||||
nullable: false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Tgstation.Server.Host.Extensions;
|
||||
|
||||
namespace Tgstation.Server.Host.Jobs
|
||||
{
|
||||
@@ -47,15 +48,12 @@ namespace Tgstation.Server.Host.Jobs
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation</param>
|
||||
/// <returns>A <see cref="Task"/> representing the running operation</returns>
|
||||
public async Task Wait(CancellationToken cancellationToken)
|
||||
public Task Wait(CancellationToken cancellationToken)
|
||||
{
|
||||
if (task == null)
|
||||
throw new InvalidOperationException("Job not started!");
|
||||
|
||||
TaskCompletionSource<object> tcs = new TaskCompletionSource<object>();
|
||||
using (cancellationToken.Register(() => tcs.SetCanceled()))
|
||||
await Task.WhenAny(tcs.Task, task).ConfigureAwait(false);
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
return task.WithToken(cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -76,4 +74,4 @@ namespace Tgstation.Server.Host.Jobs
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -298,8 +298,14 @@ namespace Tgstation.Server.Host.Jobs
|
||||
await databaseContext.Save(cancellationToken).ConfigureAwait(false);
|
||||
job.CancelledBy = user;
|
||||
}).ConfigureAwait(false);
|
||||
|
||||
if (blocking)
|
||||
{
|
||||
logger.LogTrace("Waiting on cancelled job #{0}...", job.Id);
|
||||
await handler.Wait(cancellationToken).ConfigureAwait(false);
|
||||
logger.LogTrace("Done waiting on job #{0}...", job.Id);
|
||||
}
|
||||
|
||||
return job;
|
||||
}
|
||||
|
||||
@@ -321,8 +327,6 @@ namespace Tgstation.Server.Host.Jobs
|
||||
{
|
||||
if (job == null)
|
||||
throw new ArgumentNullException(nameof(job));
|
||||
if (canceller == null)
|
||||
throw new ArgumentNullException(nameof(canceller));
|
||||
JobHandler handler;
|
||||
lock (synchronizationLock)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user