From ec248029babe6d484184b8d5d4501778588f5c76 Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Fri, 29 Jun 2018 16:50:14 -0400 Subject: [PATCH] Moh werrk? --- .../Components/DreamDaemonControl.cs | 19 +++++++++++++++++ .../DreamDaemonReattachInformation.cs | 5 +++++ .../Components/DreamDaemonRebootState.cs | 21 +++++++++++++++++++ .../Components/IDreamDaemonControl.cs | 17 +++++++++++++-- .../Components/IDreamDaemonFactory.cs | 16 ++++++++++++++ 5 files changed, 76 insertions(+), 2 deletions(-) create mode 100644 src/Tgstation.Server.Host/Components/DreamDaemonRebootState.cs create mode 100644 src/Tgstation.Server.Host/Components/IDreamDaemonFactory.cs diff --git a/src/Tgstation.Server.Host/Components/DreamDaemonControl.cs b/src/Tgstation.Server.Host/Components/DreamDaemonControl.cs index 85d8238029..272cf23d69 100644 --- a/src/Tgstation.Server.Host/Components/DreamDaemonControl.cs +++ b/src/Tgstation.Server.Host/Components/DreamDaemonControl.cs @@ -57,6 +57,16 @@ namespace Tgstation.Server.Host.Components } } + /// + public DreamDaemonRebootState RebootState + { + get + { + CheckDisposed(); + return reattachInformation.RebootState; + } + } + /// /// The up to date /// @@ -209,5 +219,14 @@ namespace Tgstation.Server.Host.Components throw new ArgumentOutOfRangeException(nameof(port), port, "port must not be zero!"); return await SetPortImpl(port, cancellatonToken).ConfigureAwait(false); } + + /// + public async Task SetRebootState(DreamDaemonRebootState newRebootState, CancellationToken cancellationToken) + { + var oldActive = RebootState != DreamDaemonRebootState.Normal; + var newActive = RebootState != DreamDaemonRebootState.Normal; + if (oldActive == newActive) + return true; + } } } diff --git a/src/Tgstation.Server.Host/Components/DreamDaemonReattachInformation.cs b/src/Tgstation.Server.Host/Components/DreamDaemonReattachInformation.cs index 75b079cec8..5c24f46e21 100644 --- a/src/Tgstation.Server.Host/Components/DreamDaemonReattachInformation.cs +++ b/src/Tgstation.Server.Host/Components/DreamDaemonReattachInformation.cs @@ -27,6 +27,11 @@ namespace Tgstation.Server.Host.Components /// public ushort Port { get; set; } + /// + /// The current DreamDaemon reboot state + /// + public DreamDaemonRebootState RebootState { get; set; } + /// /// The used by DreamDaemon /// diff --git a/src/Tgstation.Server.Host/Components/DreamDaemonRebootState.cs b/src/Tgstation.Server.Host/Components/DreamDaemonRebootState.cs new file mode 100644 index 0000000000..8608ab6005 --- /dev/null +++ b/src/Tgstation.Server.Host/Components/DreamDaemonRebootState.cs @@ -0,0 +1,21 @@ +namespace Tgstation.Server.Host.Components +{ + /// + /// Represents the action to take when /world/Reboot() is called + /// + enum DreamDaemonRebootState + { + /// + /// Run DreamDaemon's normal reboot process + /// + Normal, + /// + /// Shutdown DreamDaemon + /// + Shutdown, + /// + /// Restart the DreamDaemon process + /// + Restart + } +} diff --git a/src/Tgstation.Server.Host/Components/IDreamDaemonControl.cs b/src/Tgstation.Server.Host/Components/IDreamDaemonControl.cs index b5ecc131b9..81454a6047 100644 --- a/src/Tgstation.Server.Host/Components/IDreamDaemonControl.cs +++ b/src/Tgstation.Server.Host/Components/IDreamDaemonControl.cs @@ -7,8 +7,8 @@ namespace Tgstation.Server.Host.Components /// /// Handles communication with a /// - interface IDreamDaemonControl : IDisposable - { + interface IDreamDaemonControl : IDisposable + { /// /// If the of is being used /// @@ -24,6 +24,11 @@ namespace Tgstation.Server.Host.Components /// ushort Port { get; } + /// + /// The current + /// + DreamDaemonRebootState RebootState { get; } + /// /// Releases the without terminating it. Also calls /// @@ -50,5 +55,13 @@ namespace Tgstation.Server.Host.Components /// The for the operation /// A resulting in if the operation succeeded, otherwise Task SetPort(ushort newPort, CancellationToken cancellatonToken); + + /// + /// Attempts to change the current to + /// + /// The new + /// The for the operation + /// A resulting in if the operation succeeded, otherwise + Task SetRebootState(DreamDaemonRebootState newRebootState, CancellationToken cancellationToken); } } diff --git a/src/Tgstation.Server.Host/Components/IDreamDaemonFactory.cs b/src/Tgstation.Server.Host/Components/IDreamDaemonFactory.cs new file mode 100644 index 0000000000..76ae5ce3f4 --- /dev/null +++ b/src/Tgstation.Server.Host/Components/IDreamDaemonFactory.cs @@ -0,0 +1,16 @@ +using System.Threading; +using System.Threading.Tasks; +using Tgstation.Server.Api.Models.Internal; + +namespace Tgstation.Server.Host.Components +{ + /// + /// Factory for s + /// + interface IDreamDaemonFactory + { + IDreamDaemonControl LaunchNew(DreamDaemonLaunchParameters launchParameters); + + Task Reattach(DreamDaemonReattachInformation reattachInformation, CancellationToken cancellationToken); + } +}