diff --git a/src/Tgstation.Server.Host.Service/Program.cs b/src/Tgstation.Server.Host.Service/Program.cs
index 59c11072a7..1a5a1a9dcf 100644
--- a/src/Tgstation.Server.Host.Service/Program.cs
+++ b/src/Tgstation.Server.Host.Service/Program.cs
@@ -47,10 +47,9 @@ namespace Tgstation.Server.Host.Service
///
public void OnExecute()
{
- if((Install || Uninstall) && !IsAdministrator())
+ if ((Install || Uninstall) && !IsAdministrator())
{
//try to restart as admin
- var currentProcess = Process.GetCurrentProcess();
var argList = Environment.GetCommandLineArgs().ToList();
//its windows, first arg is .exe name guaranteed
var exe = argList.First();
diff --git a/src/Tgstation.Server.Host/Components/DreamMaker.cs b/src/Tgstation.Server.Host/Components/DreamMaker.cs
index abecf25fe8..4bf02b7873 100644
--- a/src/Tgstation.Server.Host/Components/DreamMaker.cs
+++ b/src/Tgstation.Server.Host/Components/DreamMaker.cs
@@ -8,7 +8,7 @@ using System.Threading;
using System.Threading.Tasks;
using Tgstation.Server.Api.Models;
using Tgstation.Server.Api.Models.Internal;
-using Tgstation.Server.Host.Components.Models;
+using Tgstation.Server.Host.Components.Watchdog;
using Tgstation.Server.Host.Core;
namespace Tgstation.Server.Host.Components
@@ -45,18 +45,14 @@ namespace Tgstation.Server.Host.Components
///
readonly IConfiguration configuration;
///
- /// The for
+ /// The for
///
- readonly IDreamDaemonExecutor dreamDaemonExecutor;
+ readonly ISessionControllerFactory sessionControllerFactory;
///
/// The for
///
readonly IByond byond;
///
- /// The for
- ///
- readonly IInterop interop;
- ///
/// The for
///
readonly ICompileJobConsumer compileJobConsumer;
@@ -76,13 +72,11 @@ namespace Tgstation.Server.Host.Components
/// The value of
/// The value of
///
- public DreamMaker(IIOManager ioManager, IConfiguration configuration, IDreamDaemonExecutor dreamDaemonExecutor, IByond byond, IInterop interop, ICompileJobConsumer compileJobConsumer, IApplication application)
+ public DreamMaker(IIOManager ioManager, IConfiguration configuration, ISessionControllerFactory sessionControllerFactory, ICompileJobConsumer compileJobConsumer, IApplication application)
{
this.ioManager = ioManager ?? throw new ArgumentNullException(nameof(ioManager));
this.configuration = configuration ?? throw new ArgumentNullException(nameof(configuration));
- this.dreamDaemonExecutor = dreamDaemonExecutor ?? throw new ArgumentNullException(nameof(dreamDaemonExecutor));
- this.byond = byond ?? throw new ArgumentNullException(nameof(byond));
- this.interop = interop ?? throw new ArgumentNullException(nameof(interop));
+ this.sessionControllerFactory = sessionControllerFactory ?? throw new ArgumentNullException(nameof(sessionControllerFactory));
this.compileJobConsumer = compileJobConsumer ?? throw new ArgumentNullException(nameof(compileJobConsumer));
this.application = application ?? throw new ArgumentNullException(nameof(application));
}
@@ -91,10 +85,10 @@ namespace Tgstation.Server.Host.Components
/// Run a quick DD instance to test the DMAPI is installed on the target code
///
/// The path to the DreamDaemon executable
- /// The for the operation
+ /// The for the operation
/// The for the operation
/// A resulting in if the DMAPI was successfully validated, otherwise
- async Task VerifyApi(string dreamDaemonPath, Host.Models.CompileJob job, CancellationToken cancellationToken)
+ async Task VerifyApi(string dreamDaemonPath, Models.CompileJob job, CancellationToken cancellationToken)
{
var launchParameters = new DreamDaemonLaunchParameters
{
diff --git a/src/Tgstation.Server.Host/Components/IByondExecutableLock.cs b/src/Tgstation.Server.Host/Components/IByondExecutableLock.cs
index d83f18c9ca..4da3b8eff8 100644
--- a/src/Tgstation.Server.Host/Components/IByondExecutableLock.cs
+++ b/src/Tgstation.Server.Host/Components/IByondExecutableLock.cs
@@ -2,11 +2,24 @@
namespace Tgstation.Server.Host.Components
{
+ ///
+ /// Represents usage of the two primary BYOND server executables
+ ///
public interface IByondExecutableLock : IDisposable
{
+ ///
+ /// The path to the DreamDaemon executable
+ ///
string DreamDaemonPath { get; set; }
+
+ ///
+ /// The path to the dm/DreamMaker executable
+ ///
string DreamMakerPath { get; set; }
+ ///
+ /// Call if, during a detach, this version should not be deleted
+ ///
void DoNotDeleteThisSession();
}
}
diff --git a/src/Tgstation.Server.Host/Components/IInterop.cs b/src/Tgstation.Server.Host/Components/IInterop.cs
deleted file mode 100644
index ff5337dc30..0000000000
--- a/src/Tgstation.Server.Host/Components/IInterop.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-using System;
-using System.Threading;
-using System.Threading.Tasks;
-
-namespace Tgstation.Server.Host.Components
-{
- ///
- /// Handles communication with the DMAPI
- ///
- interface IInterop
- {
- IInteropControl ReconnectToRun(string primaryAccessToken, string secondaryAccessToken, ushort primaryPort, ushort secondaryPort);
-
- IInteropControl CreateRun(ushort primaryPort, ushort? secondaryPort, Func chatMessageHandler);
- }
-}
diff --git a/src/Tgstation.Server.Host/Components/IWatchdog.cs b/src/Tgstation.Server.Host/Components/IWatchdog.cs
deleted file mode 100644
index 5504baa960..0000000000
--- a/src/Tgstation.Server.Host/Components/IWatchdog.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-using System.Threading;
-using System.Threading.Tasks;
-
-namespace Tgstation.Server.Host.Components
-{
- ///
- /// For monitoring DreamDaemon uptime
- ///
- interface IWatchdog
- {
- ///
- /// The latest used by the
- ///
- Host.Models.CompileJob CurrentCompileJob { get; }
-
- ///
- /// Start the
- ///
- /// The for the run
- /// The for the operation
- /// A representing the running operation
- Task Start(ILaunchParametersFactory launchParametersFactory, CancellationToken cancellationToken);
-
- ///
- /// Stop the
- ///
- /// A representing the running operation
- Task Stop();
- }
-}
diff --git a/src/Tgstation.Server.Host/Components/ServerControlEvent.cs b/src/Tgstation.Server.Host/Components/ServerControlEvent.cs
deleted file mode 100644
index b619b68603..0000000000
--- a/src/Tgstation.Server.Host/Components/ServerControlEvent.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-using System;
-
-namespace Tgstation.Server.Host.Components
-{
- ///
- /// Represents a DreamDaemon control request or notification
- ///
- sealed class ServerControlEvent : EventArgs
- {
- ///
- /// The
- ///
- public ServerControlEventType EventType { get; set; }
-
- ///
- /// If the message was sent from the primary server
- ///
- public bool FromPrimaryServer { get; set; }
- }
-}
\ No newline at end of file
diff --git a/src/Tgstation.Server.Host/Components/ServerControlEventType.cs b/src/Tgstation.Server.Host/Components/ServerControlEventType.cs
deleted file mode 100644
index 9468bcabaa..0000000000
--- a/src/Tgstation.Server.Host/Components/ServerControlEventType.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-namespace Tgstation.Server.Host.Components
-{
- ///
- /// Indicates a server control event from a DreamDaemon instance
- ///
- enum ServerControlEventType
- {
- ///
- /// The server is loaded
- ///
- ServerPrimed,
- ///
- /// The server called world/Reboot()
- ///
- ServerRebooting,
- ///
- /// The server requested that it's process be terminated
- ///
- RequestedProcessTermination,
- ///
- /// The server has stopped responding to heartbeats
- ///
- ServerUnresponsive,
- }
-}
\ No newline at end of file
diff --git a/src/Tgstation.Server.Host/Components/TemporaryDmbProvider.cs b/src/Tgstation.Server.Host/Components/TemporaryDmbProvider.cs
index fc4fa15408..de3c7164ac 100644
--- a/src/Tgstation.Server.Host/Components/TemporaryDmbProvider.cs
+++ b/src/Tgstation.Server.Host/Components/TemporaryDmbProvider.cs
@@ -33,5 +33,7 @@ namespace Tgstation.Server.Host.Components
///
public void Dispose() { }
+
+ public void KeepAlive() => throw new NotSupportedException();
}
}
\ No newline at end of file
diff --git a/src/Tgstation.Server.Host/Components/Watchdog/Executor.cs b/src/Tgstation.Server.Host/Components/Watchdog/Executor.cs
index 718b459917..e31b223d2a 100644
--- a/src/Tgstation.Server.Host/Components/Watchdog/Executor.cs
+++ b/src/Tgstation.Server.Host/Components/Watchdog/Executor.cs
@@ -30,15 +30,15 @@ namespace Tgstation.Server.Host.Components.Watchdog
}
///
- public ISession AttachToDreamDaemon(int processId) => new Session(Process.GetProcessById(processId));
+ public ISession AttachToDreamDaemon(int processId, IByondExecutableLock byondLock) => new Session(Process.GetProcessById(processId), byondLock);
///
- public ISession RunDreamDaemon(DreamDaemonLaunchParameters launchParameters, string dreamDaemonPath, IDmbProvider dmbProvider, string parameters, bool useSecondaryPort, bool useSecondaryDirectory)
+ public ISession RunDreamDaemon(DreamDaemonLaunchParameters launchParameters, IByondExecutableLock byondLock, IDmbProvider dmbProvider, string parameters, bool useSecondaryPort, bool useSecondaryDirectory)
{
if (launchParameters == null)
throw new ArgumentNullException(nameof(launchParameters));
- if (dreamDaemonPath == null)
- throw new ArgumentNullException(nameof(dreamDaemonPath));
+ if (byondLock == null)
+ throw new ArgumentNullException(nameof(byondLock));
if (dmbProvider == null)
throw new ArgumentNullException(nameof(dmbProvider));
if (parameters == null)
@@ -48,7 +48,7 @@ namespace Tgstation.Server.Host.Components.Watchdog
try
{
- proc.StartInfo.FileName = dreamDaemonPath;
+ proc.StartInfo.FileName = byondLock.DreamDaemonPath;
proc.StartInfo.WorkingDirectory = useSecondaryDirectory ? dmbProvider.SecondaryDirectory : dmbProvider.PrimaryDirectory;
proc.StartInfo.Arguments = String.Format(CultureInfo.InvariantCulture, "{0} -port {1} {2}-close -{3} -verbose -public -params \"{4}\"",
@@ -60,7 +60,7 @@ namespace Tgstation.Server.Host.Components.Watchdog
proc.Start();
- return new Session(proc);
+ return new Session(proc, byondLock);
}
catch
{
diff --git a/src/Tgstation.Server.Host/Components/Watchdog/IExecutor.cs b/src/Tgstation.Server.Host/Components/Watchdog/IExecutor.cs
index 5555d24030..b27a06a78f 100644
--- a/src/Tgstation.Server.Host/Components/Watchdog/IExecutor.cs
+++ b/src/Tgstation.Server.Host/Components/Watchdog/IExecutor.cs
@@ -12,18 +12,19 @@ namespace Tgstation.Server.Host.Components.Watchdog
///
/// The
/// The that is completed when dream daemon starts without crashing
- /// The path to the dreamdaemon executable
+ /// The for the new
/// The for the .dmb to run
/// The value of the -params command line option
/// If the field of should be used
/// A new
- ISession RunDreamDaemon(DreamDaemonLaunchParameters launchParameters, string dreamDaemonPath, IDmbProvider dmbProvider, string parameters, bool useSecondaryPort, bool useSecondaryDirectory);
+ ISession RunDreamDaemon(DreamDaemonLaunchParameters launchParameters, IByondExecutableLock byondLock, IDmbProvider dmbProvider, string parameters, bool useSecondaryPort, bool useSecondaryDirectory);
///
/// Attach to a running instance of DreamDaemon
///
/// The
+ /// The for the new
/// A new
- ISession AttachToDreamDaemon(int processId);
+ ISession AttachToDreamDaemon(int processId, IByondExecutableLock byondLock);
}
}
diff --git a/src/Tgstation.Server.Host/Components/Watchdog/Session.cs b/src/Tgstation.Server.Host/Components/Watchdog/Session.cs
index 5bd85ab417..e978b66003 100644
--- a/src/Tgstation.Server.Host/Components/Watchdog/Session.cs
+++ b/src/Tgstation.Server.Host/Components/Watchdog/Session.cs
@@ -20,6 +20,11 @@ namespace Tgstation.Server.Host.Components.Watchdog
/// The actual
///
readonly Process process;
+ ///
+ /// The for the
+ ///
+ readonly IByondExecutableLock byondLock;
+
///
/// The backing for
///
@@ -29,9 +34,11 @@ namespace Tgstation.Server.Host.Components.Watchdog
/// Construct a
///
/// The value of
- public Session(Process process)
+ /// The value of
+ public Session(Process process, IByondExecutableLock byondLock)
{
this.process = process ?? throw new ArgumentNullException(nameof(process));
+ this.byondLock = byondLock ?? throw new ArgumentNullException(nameof(byondLock));
LaunchResult = Task.Factory.StartNew(() =>
{
diff --git a/src/Tgstation.Server.Host/Components/Watchdog/SessionControllerFactory.cs b/src/Tgstation.Server.Host/Components/Watchdog/SessionControllerFactory.cs
index 81e1ecc9aa..aae84ea84a 100644
--- a/src/Tgstation.Server.Host/Components/Watchdog/SessionControllerFactory.cs
+++ b/src/Tgstation.Server.Host/Components/Watchdog/SessionControllerFactory.cs
@@ -110,7 +110,10 @@ namespace Tgstation.Server.Host.Components.Watchdog
var byondLock = byond.UseExecutables(dmbProvider.CompileJob.ByondVersion);
try
{
- var session = executor.RunDreamDaemon(launchParameters, byondLock, dmbProvider, /*TODO*/, !primaryPort, !primaryDirectory);
+ var parameters = String.Format(CultureInfo.InvariantCulture, "server_service_version={0}&tgs_json={1}", application.Version, interopJsonFile);
+
+
+ var session = executor.RunDreamDaemon(launchParameters, byondLock, dmbProvider, parameters, !primaryPort, !primaryDirectory);
try
{
return new SessionController(new ReattachInformation
diff --git a/src/Tgstation.Server.Host/Components/Watchdog/Watchdog.cs b/src/Tgstation.Server.Host/Components/Watchdog/Watchdog.cs
index 2acb52dfea..4152b8bfb4 100644
--- a/src/Tgstation.Server.Host/Components/Watchdog/Watchdog.cs
+++ b/src/Tgstation.Server.Host/Components/Watchdog/Watchdog.cs
@@ -1,4 +1,6 @@
using System;
+using System.Threading;
+using System.Threading.Tasks;
using Tgstation.Server.Api.Models.Internal;
namespace Tgstation.Server.Host.Components.Watchdog
@@ -6,6 +8,7 @@ namespace Tgstation.Server.Host.Components.Watchdog
///
sealed class Watchdog : IWatchdog
{
+ ///
public DreamDaemonLaunchParameters LaunchParameters
{
get => launchParameters;
@@ -74,5 +77,8 @@ namespace Tgstation.Server.Host.Components.Watchdog
disposed = true;
}
}
+
+ ///
+ public Task Launch(CancellationToken cancellationToken) => throw new NotImplementedException();
}
}