diff --git a/src/Tgstation.Server.Host/Components/InstanceManager.cs b/src/Tgstation.Server.Host/Components/InstanceManager.cs
index 044169edc7..094b3d4db1 100644
--- a/src/Tgstation.Server.Host/Components/InstanceManager.cs
+++ b/src/Tgstation.Server.Host/Components/InstanceManager.cs
@@ -455,13 +455,20 @@ namespace Tgstation.Server.Host.Components
///
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);
+ }
}
///
diff --git a/src/Tgstation.Server.Host/Components/Session/ISessionController.cs b/src/Tgstation.Server.Host/Components/Session/ISessionController.cs
index c85171fb56..778c39ba38 100644
--- a/src/Tgstation.Server.Host/Components/Session/ISessionController.cs
+++ b/src/Tgstation.Server.Host/Components/Session/ISessionController.cs
@@ -38,11 +38,6 @@ namespace Tgstation.Server.Host.Components.Session
///
CompileJob CompileJob { get; }
- ///
- /// The current port DreamDaemon is listening on
- ///
- ushort? Port { get; }
-
///
/// If the port should be rotated off when the world reboots
///
diff --git a/src/Tgstation.Server.Host/Components/Session/SessionController.cs b/src/Tgstation.Server.Host/Components/Session/SessionController.cs
index e790feb310..e06caba888 100644
--- a/src/Tgstation.Server.Host/Components/Session/SessionController.cs
+++ b/src/Tgstation.Server.Host/Components/Session/SessionController.cs
@@ -42,26 +42,7 @@ namespace Tgstation.Server.Host.Components.Session
public Models.CompileJob CompileJob => reattachInformation.Dmb.CompileJob;
///
- public ushort? Port
- {
- get
- {
- CheckDisposed();
- if (portClosedForReboot)
- return null;
- return reattachInformation.Port;
- }
- }
-
- ///
- public RebootState RebootState
- {
- get
- {
- CheckDisposed();
- return reattachInformation.RebootState;
- }
- }
+ public RebootState RebootState => reattachInformation.RebootState;
///
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);
}
///
diff --git a/src/Tgstation.Server.Host/Components/StaticFiles/Configuration.cs b/src/Tgstation.Server.Host/Components/StaticFiles/Configuration.cs
index a61ba8cea7..12eb031994 100644
--- a/src/Tgstation.Server.Host/Components/StaticFiles/Configuration.cs
+++ b/src/Tgstation.Server.Host/Components/StaticFiles/Configuration.cs
@@ -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);
}
+ }
}
}
diff --git a/src/Tgstation.Server.Host/Database/Design/DesignTimeDbContextFactoryHelpers.cs b/src/Tgstation.Server.Host/Database/Design/DesignTimeDbContextFactoryHelpers.cs
index 4d4f4411dd..36da823aa4 100644
--- a/src/Tgstation.Server.Host/Database/Design/DesignTimeDbContextFactoryHelpers.cs
+++ b/src/Tgstation.Server.Host/Database/Design/DesignTimeDbContextFactoryHelpers.cs
@@ -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
/// The to create for.
/// The .
/// The .
+ /// The .
/// The for the
public static DbContextOptions CreateDatabaseContextOptions(
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();
diff --git a/src/Tgstation.Server.Host/Database/Migrations/20200423052709_MYKillJsonsAddDMApiVersion.cs b/src/Tgstation.Server.Host/Database/Migrations/20200423052709_MYKillJsonsAddDMApiVersion.cs
index 9c6ed01066..32e03425c8 100644
--- a/src/Tgstation.Server.Host/Database/Migrations/20200423052709_MYKillJsonsAddDMApiVersion.cs
+++ b/src/Tgstation.Server.Host/Database/Migrations/20200423052709_MYKillJsonsAddDMApiVersion.cs
@@ -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(
name: "ChatChannelsJson",
table: "ReattachInformations",
type: "longtext CHARACTER SET utf8mb4",
- nullable: false,
- defaultValue: "chat_channels.tgs.json");
+ nullable: false);
migrationBuilder.AddColumn(
name: "ChatCommandsJson",
table: "ReattachInformations",
type: "longtext CHARACTER SET utf8mb4",
- nullable: false,
- defaultValue: "chat_commands.tgs.json");
+ nullable: false);
}
}
}
diff --git a/src/Tgstation.Server.Host/Jobs/JobHandler.cs b/src/Tgstation.Server.Host/Jobs/JobHandler.cs
index 86437139d5..c6b923033c 100644
--- a/src/Tgstation.Server.Host/Jobs/JobHandler.cs
+++ b/src/Tgstation.Server.Host/Jobs/JobHandler.cs
@@ -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
///
/// The for the operation
/// A representing the running operation
- public async Task Wait(CancellationToken cancellationToken)
+ public Task Wait(CancellationToken cancellationToken)
{
if (task == null)
throw new InvalidOperationException("Job not started!");
- TaskCompletionSource