From 253acf08b41a69a65e9d27f6bfe8f3e44efd3006 Mon Sep 17 00:00:00 2001
From: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com>
Date: Sat, 9 Jan 2021 22:26:14 +0000
Subject: [PATCH 1/5] DNM - Initial Commit
---
.../Components/Events/EventType.cs | 8 +++++++-
.../Components/InstanceFactory.cs | 3 ++-
.../Components/Session/SessionController.cs | 13 +++++++++++--
.../Components/Watchdog/README.md | 2 +-
4 files changed, 21 insertions(+), 5 deletions(-)
diff --git a/src/Tgstation.Server.Host/Components/Events/EventType.cs b/src/Tgstation.Server.Host/Components/Events/EventType.cs
index 9085c6e215..93fe022964 100644
--- a/src/Tgstation.Server.Host/Components/Events/EventType.cs
+++ b/src/Tgstation.Server.Host/Components/Events/EventType.cs
@@ -111,6 +111,12 @@ namespace Tgstation.Server.Host.Components.Events
/// Before the watchdog launches. No parameters.
///
[EventScript("WatchdogLaunch")]
- WatchdogLaunch
+ WatchdogLaunch,
+
+ ///
+ /// Inbetween DD restarts if the process has been force-ended by the DMAPI
+ ///
+ [EventScript("DDEndProcess")]
+ DDEndProcess
}
}
diff --git a/src/Tgstation.Server.Host/Components/InstanceFactory.cs b/src/Tgstation.Server.Host/Components/InstanceFactory.cs
index cd04474fb4..8296da7f35 100644
--- a/src/Tgstation.Server.Host/Components/InstanceFactory.cs
+++ b/src/Tgstation.Server.Host/Components/InstanceFactory.cs
@@ -273,7 +273,8 @@ namespace Tgstation.Server.Host.Components
serverPortProvider,
loggerFactory,
loggerFactory.CreateLogger(),
- metadata.CloneMetadata());
+ metadata.CloneMetadata(),
+ eventConsumer);
var dmbFactory = new DmbFactory(
databaseContextFactory,
diff --git a/src/Tgstation.Server.Host/Components/Session/SessionController.cs b/src/Tgstation.Server.Host/Components/Session/SessionController.cs
index 1462b6cd50..47317b6474 100644
--- a/src/Tgstation.Server.Host/Components/Session/SessionController.cs
+++ b/src/Tgstation.Server.Host/Components/Session/SessionController.cs
@@ -14,6 +14,7 @@ using Tgstation.Server.Api.Models;
using Tgstation.Server.Host.Components.Byond;
using Tgstation.Server.Host.Components.Chat;
using Tgstation.Server.Host.Components.Deployment;
+using Tgstation.Server.Host.Components.Events;
using Tgstation.Server.Host.Components.Interop;
using Tgstation.Server.Host.Components.Interop.Bridge;
using Tgstation.Server.Host.Components.Interop.Topic;
@@ -168,6 +169,11 @@ namespace Tgstation.Server.Host.Components.Session
///
bool released;
+ ///
+ /// The
+ ///
+ readonly IEventConsumer eventConsumer;
+
///
/// Construct a
///
@@ -185,6 +191,7 @@ namespace Tgstation.Server.Host.Components.Session
/// The optional time to wait before failing the
/// If this is a reattached session.
/// If this is a DMAPI validation session.
+ /// The value of .
public SessionController(
ReattachInformation reattachInformation,
Api.Models.Instance metadata,
@@ -199,7 +206,8 @@ namespace Tgstation.Server.Host.Components.Session
Func postLifetimeCallback,
uint? startupTimeout,
bool reattached,
- bool apiValidate)
+ bool apiValidate,
+ IEventConsumer eventConsumer)
{
this.reattachInformation = reattachInformation ?? throw new ArgumentNullException(nameof(reattachInformation));
this.metadata = metadata ?? throw new ArgumentNullException(nameof(metadata));
@@ -211,7 +219,7 @@ namespace Tgstation.Server.Host.Components.Session
throw new ArgumentNullException(nameof(bridgeRegistrar));
this.chat = chat ?? throw new ArgumentNullException(nameof(chat));
this.logger = logger ?? throw new ArgumentNullException(nameof(logger));
-
+ this.eventConsumer = eventConsumer ?? throw new ArgumentNullException(nameof(eventConsumer));
portClosedForReboot = false;
disposed = false;
apiValidationStatus = ApiValidationStatus.NeverValidated;
@@ -393,6 +401,7 @@ namespace Tgstation.Server.Host.Components.Session
logger.LogInformation("Bridge requested process termination!");
TerminationWasRequested = true;
process.Terminate();
+ eventConsumer.HandleEvent(EventType.DDEndProcess, Enumerable.Empty(), cancellationToken);
break;
case BridgeCommandType.PortUpdate:
lock (synchronizationLock)
diff --git a/src/Tgstation.Server.Host/Components/Watchdog/README.md b/src/Tgstation.Server.Host/Components/Watchdog/README.md
index f9846a0db7..229dc45032 100644
--- a/src/Tgstation.Server.Host/Components/Watchdog/README.md
+++ b/src/Tgstation.Server.Host/Components/Watchdog/README.md
@@ -29,7 +29,7 @@ From the perspective of `WatchdogBase`
Watchdog monitoring takes place in the `MonitorLifetimes()` functiona and is entirely event based. It responds to a set of [MonitorActivationReason](./MonitorActivationReason.cs)s and takes the apporprate action. This includes:
- When a server crashes.
-- When a server calls `/world/prod/Reboot()`.
+- When a server calls `/world/proc/Reboot()`.
- When a new .dmb is deployed.
- When DreamDaemon settings are changed via the API.
- When it is time to make a heartbeat.
From 129d1e7b631b051e9034ac458e3e23d3016f0c5b Mon Sep 17 00:00:00 2001
From: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com>
Date: Sun, 10 Jan 2021 13:19:58 +0000
Subject: [PATCH 2/5] Revert "DNM - Initial Commit"
This reverts commit 253acf08b41a69a65e9d27f6bfe8f3e44efd3006.
---
.../Components/Events/EventType.cs | 8 +-------
.../Components/InstanceFactory.cs | 3 +--
.../Components/Session/SessionController.cs | 13 ++-----------
.../Components/Watchdog/README.md | 2 +-
4 files changed, 5 insertions(+), 21 deletions(-)
diff --git a/src/Tgstation.Server.Host/Components/Events/EventType.cs b/src/Tgstation.Server.Host/Components/Events/EventType.cs
index 93fe022964..9085c6e215 100644
--- a/src/Tgstation.Server.Host/Components/Events/EventType.cs
+++ b/src/Tgstation.Server.Host/Components/Events/EventType.cs
@@ -111,12 +111,6 @@ namespace Tgstation.Server.Host.Components.Events
/// Before the watchdog launches. No parameters.
///
[EventScript("WatchdogLaunch")]
- WatchdogLaunch,
-
- ///
- /// Inbetween DD restarts if the process has been force-ended by the DMAPI
- ///
- [EventScript("DDEndProcess")]
- DDEndProcess
+ WatchdogLaunch
}
}
diff --git a/src/Tgstation.Server.Host/Components/InstanceFactory.cs b/src/Tgstation.Server.Host/Components/InstanceFactory.cs
index 8296da7f35..cd04474fb4 100644
--- a/src/Tgstation.Server.Host/Components/InstanceFactory.cs
+++ b/src/Tgstation.Server.Host/Components/InstanceFactory.cs
@@ -273,8 +273,7 @@ namespace Tgstation.Server.Host.Components
serverPortProvider,
loggerFactory,
loggerFactory.CreateLogger(),
- metadata.CloneMetadata(),
- eventConsumer);
+ metadata.CloneMetadata());
var dmbFactory = new DmbFactory(
databaseContextFactory,
diff --git a/src/Tgstation.Server.Host/Components/Session/SessionController.cs b/src/Tgstation.Server.Host/Components/Session/SessionController.cs
index 47317b6474..1462b6cd50 100644
--- a/src/Tgstation.Server.Host/Components/Session/SessionController.cs
+++ b/src/Tgstation.Server.Host/Components/Session/SessionController.cs
@@ -14,7 +14,6 @@ using Tgstation.Server.Api.Models;
using Tgstation.Server.Host.Components.Byond;
using Tgstation.Server.Host.Components.Chat;
using Tgstation.Server.Host.Components.Deployment;
-using Tgstation.Server.Host.Components.Events;
using Tgstation.Server.Host.Components.Interop;
using Tgstation.Server.Host.Components.Interop.Bridge;
using Tgstation.Server.Host.Components.Interop.Topic;
@@ -169,11 +168,6 @@ namespace Tgstation.Server.Host.Components.Session
///
bool released;
- ///
- /// The
- ///
- readonly IEventConsumer eventConsumer;
-
///
/// Construct a
///
@@ -191,7 +185,6 @@ namespace Tgstation.Server.Host.Components.Session
/// The optional time to wait before failing the
/// If this is a reattached session.
/// If this is a DMAPI validation session.
- /// The value of .
public SessionController(
ReattachInformation reattachInformation,
Api.Models.Instance metadata,
@@ -206,8 +199,7 @@ namespace Tgstation.Server.Host.Components.Session
Func postLifetimeCallback,
uint? startupTimeout,
bool reattached,
- bool apiValidate,
- IEventConsumer eventConsumer)
+ bool apiValidate)
{
this.reattachInformation = reattachInformation ?? throw new ArgumentNullException(nameof(reattachInformation));
this.metadata = metadata ?? throw new ArgumentNullException(nameof(metadata));
@@ -219,7 +211,7 @@ namespace Tgstation.Server.Host.Components.Session
throw new ArgumentNullException(nameof(bridgeRegistrar));
this.chat = chat ?? throw new ArgumentNullException(nameof(chat));
this.logger = logger ?? throw new ArgumentNullException(nameof(logger));
- this.eventConsumer = eventConsumer ?? throw new ArgumentNullException(nameof(eventConsumer));
+
portClosedForReboot = false;
disposed = false;
apiValidationStatus = ApiValidationStatus.NeverValidated;
@@ -401,7 +393,6 @@ namespace Tgstation.Server.Host.Components.Session
logger.LogInformation("Bridge requested process termination!");
TerminationWasRequested = true;
process.Terminate();
- eventConsumer.HandleEvent(EventType.DDEndProcess, Enumerable.Empty(), cancellationToken);
break;
case BridgeCommandType.PortUpdate:
lock (synchronizationLock)
diff --git a/src/Tgstation.Server.Host/Components/Watchdog/README.md b/src/Tgstation.Server.Host/Components/Watchdog/README.md
index 229dc45032..f9846a0db7 100644
--- a/src/Tgstation.Server.Host/Components/Watchdog/README.md
+++ b/src/Tgstation.Server.Host/Components/Watchdog/README.md
@@ -29,7 +29,7 @@ From the perspective of `WatchdogBase`
Watchdog monitoring takes place in the `MonitorLifetimes()` functiona and is entirely event based. It responds to a set of [MonitorActivationReason](./MonitorActivationReason.cs)s and takes the apporprate action. This includes:
- When a server crashes.
-- When a server calls `/world/proc/Reboot()`.
+- When a server calls `/world/prod/Reboot()`.
- When a new .dmb is deployed.
- When DreamDaemon settings are changed via the API.
- When it is time to make a heartbeat.
From a447dd323dcf07b57c7b79b590ccefc7f485712d Mon Sep 17 00:00:00 2001
From: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com>
Date: Sun, 10 Jan 2021 14:06:02 +0000
Subject: [PATCH 3/5] V2
---
src/Tgstation.Server.Host/Components/Events/EventType.cs | 8 +++++++-
.../Components/Watchdog/BasicWatchdog.cs | 4 ++++
.../Components/Watchdog/WatchdogBase.cs | 2 +-
3 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/src/Tgstation.Server.Host/Components/Events/EventType.cs b/src/Tgstation.Server.Host/Components/Events/EventType.cs
index 9085c6e215..4e20113171 100644
--- a/src/Tgstation.Server.Host/Components/Events/EventType.cs
+++ b/src/Tgstation.Server.Host/Components/Events/EventType.cs
@@ -111,6 +111,12 @@ namespace Tgstation.Server.Host.Components.Events
/// Before the watchdog launches. No parameters.
///
[EventScript("WatchdogLaunch")]
- WatchdogLaunch
+ WatchdogLaunch,
+
+ ///
+ /// Inbetween DD restarts if the process has been force-ended by the DMAPI (TgsEndProcess())
+ ///
+ [EventScript("WorldEndProcess")]
+ WorldEndProcess,
}
}
diff --git a/src/Tgstation.Server.Host/Components/Watchdog/BasicWatchdog.cs b/src/Tgstation.Server.Host/Components/Watchdog/BasicWatchdog.cs
index c364a8cf65..4a83eab388 100644
--- a/src/Tgstation.Server.Host/Components/Watchdog/BasicWatchdog.cs
+++ b/src/Tgstation.Server.Host/Components/Watchdog/BasicWatchdog.cs
@@ -1,6 +1,7 @@
using Microsoft.Extensions.Logging;
using System;
using System.Globalization;
+using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Tgstation.Server.Api.Models.Internal;
@@ -91,6 +92,9 @@ namespace Tgstation.Server.Host.Components.Watchdog
switch (reason)
{
case MonitorActivationReason.ActiveServerCrashed:
+ if (Server.TerminationWasRequested)
+ await eventConsumer.HandleEvent(EventType.WorldEndProcess, Enumerable.Empty(), cancellationToken).ConfigureAwait(false);
+
string exitWord = Server.TerminationWasRequested ? "exited" : "crashed";
if (Server.RebootState == Session.RebootState.Shutdown)
{
diff --git a/src/Tgstation.Server.Host/Components/Watchdog/WatchdogBase.cs b/src/Tgstation.Server.Host/Components/Watchdog/WatchdogBase.cs
index 5a24b01076..e1c8336752 100644
--- a/src/Tgstation.Server.Host/Components/Watchdog/WatchdogBase.cs
+++ b/src/Tgstation.Server.Host/Components/Watchdog/WatchdogBase.cs
@@ -121,7 +121,7 @@ namespace Tgstation.Server.Host.Components.Watchdog
///
/// The that is not the
///
- readonly IEventConsumer eventConsumer;
+ public IEventConsumer eventConsumer;
///
/// The for the .
From f678d6c0d6476591f076f2ce9b17b9386423e341 Mon Sep 17 00:00:00 2001
From: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com>
Date: Sun, 10 Jan 2021 18:52:15 +0000
Subject: [PATCH 4/5] Cybertweaks
---
build/Version.props | 2 +-
src/DMAPI/tgs.dm | 4 +++-
.../Components/Events/EventType.cs | 2 +-
.../Components/Watchdog/BasicWatchdog.cs | 2 +-
.../Components/Watchdog/WatchdogBase.cs | 18 +++++++--------
.../PublishProfiles/FolderProfile.pubxml | 22 +++++++++++++++++++
6 files changed, 37 insertions(+), 13 deletions(-)
create mode 100644 src/Tgstation.Server.Host/Properties/PublishProfiles/FolderProfile.pubxml
diff --git a/build/Version.props b/build/Version.props
index 44647f7611..7214e884f4 100644
--- a/build/Version.props
+++ b/build/Version.props
@@ -7,7 +7,7 @@
2.2.0
8.2.0
9.1.1
- 5.2.10
+ 5.2.11
1.1.0
1.2.0
diff --git a/src/DMAPI/tgs.dm b/src/DMAPI/tgs.dm
index 3225f14d8c..e1eac9f291 100644
--- a/src/DMAPI/tgs.dm
+++ b/src/DMAPI/tgs.dm
@@ -1,6 +1,6 @@
// tgstation-server DMAPI
-#define TGS_DMAPI_VERSION "5.2.10"
+#define TGS_DMAPI_VERSION "5.2.11"
// All functions and datums outside this document are subject to change with any version and should not be relied on.
@@ -97,6 +97,8 @@
#define TGS_EVENT_WATCHDOG_DETACH 16
// We don't actually implement this value as the DMAPI can never receive it
// #define TGS_EVENT_WATCHDOG_LAUNCH 17
+// Same here. We don't actually implement this value as the DMAPI can never receive it
+// #define TGS_EVENT_WORLD_END_PROCESS 18
// OTHER ENUMS
diff --git a/src/Tgstation.Server.Host/Components/Events/EventType.cs b/src/Tgstation.Server.Host/Components/Events/EventType.cs
index 4e20113171..f22c1db8e0 100644
--- a/src/Tgstation.Server.Host/Components/Events/EventType.cs
+++ b/src/Tgstation.Server.Host/Components/Events/EventType.cs
@@ -114,7 +114,7 @@ namespace Tgstation.Server.Host.Components.Events
WatchdogLaunch,
///
- /// Inbetween DD restarts if the process has been force-ended by the DMAPI (TgsEndProcess())
+ /// In between DD restarts if the process has been force-ended by the DMAPI (TgsEndProcess())
///
[EventScript("WorldEndProcess")]
WorldEndProcess,
diff --git a/src/Tgstation.Server.Host/Components/Watchdog/BasicWatchdog.cs b/src/Tgstation.Server.Host/Components/Watchdog/BasicWatchdog.cs
index 4a83eab388..433680a941 100644
--- a/src/Tgstation.Server.Host/Components/Watchdog/BasicWatchdog.cs
+++ b/src/Tgstation.Server.Host/Components/Watchdog/BasicWatchdog.cs
@@ -93,7 +93,7 @@ namespace Tgstation.Server.Host.Components.Watchdog
{
case MonitorActivationReason.ActiveServerCrashed:
if (Server.TerminationWasRequested)
- await eventConsumer.HandleEvent(EventType.WorldEndProcess, Enumerable.Empty(), cancellationToken).ConfigureAwait(false);
+ await EventConsumer.HandleEvent(EventType.WorldEndProcess, Enumerable.Empty(), cancellationToken).ConfigureAwait(false);
string exitWord = Server.TerminationWasRequested ? "exited" : "crashed";
if (Server.RebootState == Session.RebootState.Shutdown)
diff --git a/src/Tgstation.Server.Host/Components/Watchdog/WatchdogBase.cs b/src/Tgstation.Server.Host/Components/Watchdog/WatchdogBase.cs
index e1c8336752..f6a7ed6160 100644
--- a/src/Tgstation.Server.Host/Components/Watchdog/WatchdogBase.cs
+++ b/src/Tgstation.Server.Host/Components/Watchdog/WatchdogBase.cs
@@ -83,6 +83,11 @@ namespace Tgstation.Server.Host.Components.Watchdog
///
protected IAsyncDelayer AsyncDelayer { get; }
+ ///
+ /// The that is not the
+ ///
+ protected IEventConsumer EventConsumer { get; }
+
///
/// The for the .
///
@@ -118,11 +123,6 @@ namespace Tgstation.Server.Host.Components.Watchdog
///
readonly IIOManager diagnosticsIOManager;
- ///
- /// The that is not the
- ///
- public IEventConsumer eventConsumer;
-
///
/// The for the .
///
@@ -179,7 +179,7 @@ namespace Tgstation.Server.Host.Components.Watchdog
/// The to populate with
/// The value of .
/// The value of .
- /// The value of .
+ /// The value of .
/// The value of .
/// The value of
/// The initial value of . May be modified
@@ -208,7 +208,7 @@ namespace Tgstation.Server.Host.Components.Watchdog
this.jobManager = jobManager ?? throw new ArgumentNullException(nameof(jobManager));
AsyncDelayer = asyncDelayer ?? throw new ArgumentNullException(nameof(asyncDelayer));
this.diagnosticsIOManager = diagnosticsIOManager ?? throw new ArgumentNullException(nameof(diagnosticsIOManager));
- this.eventConsumer = eventConsumer ?? throw new ArgumentNullException(nameof(eventConsumer));
+ EventConsumer = eventConsumer ?? throw new ArgumentNullException(nameof(eventConsumer));
this.remoteDeploymentManagerFactory = remoteDeploymentManagerFactory ?? throw new ArgumentNullException(nameof(remoteDeploymentManagerFactory));
Logger = logger ?? throw new ArgumentNullException(nameof(logger));
ActiveLaunchParameters = initialLaunchParameters ?? throw new ArgumentNullException(nameof(initialLaunchParameters));
@@ -267,7 +267,7 @@ namespace Tgstation.Server.Host.Components.Watchdog
return;
if (!graceful)
{
- var eventTask = eventConsumer.HandleEvent(releaseServers ? EventType.WatchdogDetach : EventType.WatchdogShutdown, null, cancellationToken);
+ var eventTask = EventConsumer.HandleEvent(releaseServers ? EventType.WatchdogDetach : EventType.WatchdogShutdown, null, cancellationToken);
var chatTask = announce ? Chat.QueueWatchdogMessage("Shutting down...", cancellationToken) : Task.CompletedTask;
@@ -378,7 +378,7 @@ namespace Tgstation.Server.Host.Components.Watchdog
cancellationToken); // simple announce
if (reattachInfo == null)
announceTask = Task.WhenAll(
- eventConsumer.HandleEvent(EventType.WatchdogLaunch, Enumerable.Empty(), cancellationToken),
+ EventConsumer.HandleEvent(EventType.WatchdogLaunch, Enumerable.Empty(), cancellationToken),
announceTask);
}
else
diff --git a/src/Tgstation.Server.Host/Properties/PublishProfiles/FolderProfile.pubxml b/src/Tgstation.Server.Host/Properties/PublishProfiles/FolderProfile.pubxml
new file mode 100644
index 0000000000..a23e825bed
--- /dev/null
+++ b/src/Tgstation.Server.Host/Properties/PublishProfiles/FolderProfile.pubxml
@@ -0,0 +1,22 @@
+
+
+
+
+ FileSystem
+ FileSystem
+ Release
+ Any CPU
+
+ True
+ False
+ netcoreapp3.1
+ linux-x64
+ 2b69ad6d-2b5a-4023-8ead-0bd1b18e028a
+ false
+ bin\Release\netcoreapp3.1\publish\
+ False
+
+
\ No newline at end of file
From 95906f3bbbbb28a87ed1a345f52e3d5b41ee62dd Mon Sep 17 00:00:00 2001
From: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com>
Date: Sun, 10 Jan 2021 19:25:14 +0000
Subject: [PATCH 5/5] VS Why
---
.../PublishProfiles/FolderProfile.pubxml | 22 -------------------
1 file changed, 22 deletions(-)
delete mode 100644 src/Tgstation.Server.Host/Properties/PublishProfiles/FolderProfile.pubxml
diff --git a/src/Tgstation.Server.Host/Properties/PublishProfiles/FolderProfile.pubxml b/src/Tgstation.Server.Host/Properties/PublishProfiles/FolderProfile.pubxml
deleted file mode 100644
index a23e825bed..0000000000
--- a/src/Tgstation.Server.Host/Properties/PublishProfiles/FolderProfile.pubxml
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
-
- FileSystem
- FileSystem
- Release
- Any CPU
-
- True
- False
- netcoreapp3.1
- linux-x64
- 2b69ad6d-2b5a-4023-8ead-0bd1b18e028a
- false
- bin\Release\netcoreapp3.1\publish\
- False
-
-
\ No newline at end of file