Fix release build

This commit is contained in:
Cyberboss
2018-07-10 12:05:58 -04:00
parent 8ddb6adf91
commit 59b855156b
17 changed files with 79 additions and 33 deletions
@@ -13,7 +13,7 @@ namespace Tgstation.Server.Api.Rights
/// </summary>
None = 0,
/// <summary>
/// User can read <see cref="Models.DreamDaemon.CompileJob"/>
/// User can read <see cref="Models.DreamDaemon.ActiveCompileJob"/> and <see cref="Models.DreamDaemon.StagedCompileJob"/>
/// </summary>
ReadRevision = 1,
/// <summary>
@@ -2,6 +2,9 @@
namespace Tgstation.Server.Host.Components.Chat
{
/// <summary>
/// Represents a tracking of dynamic chat json files
/// </summary>
public interface IChatJsonTrackingContext : IDisposable
{
}
@@ -67,8 +67,7 @@ namespace Tgstation.Server.Host.Components
/// <param name="byond">The value of <see cref="byond"/></param>
/// <param name="ioManager">The value of <see cref="ioManager"/></param>
/// <param name="configuration">The value of <see cref="configuration"/></param>
/// <param name="dreamDaemonExecutor">The value of <see cref="dreamDaemonExecutor"/></param>
/// <param name="interop">The value of <see cref="interop"/></param>
/// <param name="sessionControllerFactory">The value of <see cref="sessionControllerFactory"/></param>
/// <param name="compileJobConsumer">The value of <see cref="compileJobConsumer"/></param>
/// <param name="application">The value of <see cref="application"/></param>
///
@@ -85,12 +84,11 @@ namespace Tgstation.Server.Host.Components
/// <summary>
/// Run a quick DD instance to test the DMAPI is installed on the target code
/// </summary>
/// <param name="dreamDaemonPath">The path to the DreamDaemon executable</param>
/// <param name="timeout">The timeout in seconds for validation</param>
/// <param name="job">The <see cref="Models.CompileJob"/> for the operation</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation</param>
/// <returns>A <see cref="Task{TResult}"/> resulting in <see langword="true"/> if the DMAPI was successfully validated, <see langword="false"/> otherwise</returns>
async Task<bool> VerifyApi(string dreamDaemonPath, int timeout, Models.CompileJob job, CancellationToken cancellationToken)
async Task<bool> VerifyApi(int timeout, Models.CompileJob job, CancellationToken cancellationToken)
{
var launchParameters = new DreamDaemonLaunchParameters
{
@@ -268,7 +266,7 @@ namespace Tgstation.Server.Host.Components
Status = CompilerStatus.Verifying;
ddVerified = job.ExitCode == 0 && await VerifyApi(byondLock.DreamDaemonPath, apiValidateTimeout, job, cancellationToken).ConfigureAwait(false);
ddVerified = job.ExitCode == 0 && await VerifyApi(apiValidateTimeout, job, cancellationToken).ConfigureAwait(false);
}
if (!ddVerified)
@@ -1,5 +1,6 @@
using Microsoft.Extensions.Hosting;
using System.Threading.Tasks;
using Tgstation.Server.Host.Components.Chat;
using Tgstation.Server.Host.Components.Watchdog;
namespace Tgstation.Server.Host.Components
@@ -45,6 +45,7 @@ namespace Tgstation.Server.Host.Components
/// Handle a GET via world/Export
/// </summary>
/// <param name="query">The request query</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation</param>
/// <returns>A <see cref="Task{TResult}"/> resulting in an <see cref="object"/> graph that can be jsonified</returns>
Task<object> HandleWorldExport(IQueryCollection query, CancellationToken cancellationToken);
}
@@ -1,7 +1,7 @@
namespace Tgstation.Server.Host.Components
{
/// <summary>
/// Creates <see cref="IInteropContext"/>s for <see cref="IInteropConsumers"/>
/// Creates <see cref="IInteropContext"/>s for <see cref="IInteropConsumer"/>s
/// </summary>
interface IInteropRegistrar
{
@@ -11,11 +11,11 @@ namespace Tgstation.Server.Host.Components.Watchdog
/// Run a dream daemon instance
/// </summary>
/// <param name="launchParameters">The <see cref="DreamDaemonLaunchParameters"/></param>
/// <param name="onSuccessfulStartup">The <see cref="TaskCompletionSource{TResult}"/> that is completed when dream daemon starts without crashing</param>
/// <param name="byondLock">The <see cref="IByondExecutableLock"/> for the new <see cref="ISession"/></param>
/// <param name="dmbProvider">The <see cref="IDmbProvider"/> for the .dmb to run</param>
/// <param name="parameters">The value of the -params command line option</param>
/// <param name="useSecondaryPort">If the <see cref="DreamDaemonLaunchParameters.SecondaryPort"/> field of <paramref name="launchParameters"/> should be used</param>
/// <param name="useSecondaryDirectory">If the <see cref="IDmbProvider.SecondaryDirectory"/> field of <paramref name="dmbProvider"/> should be used</param>
/// <returns>A new <see cref="ISession"/></returns>
ISession RunDreamDaemon(DreamDaemonLaunchParameters launchParameters, IByondExecutableLock byondLock, IDmbProvider dmbProvider, string parameters, bool useSecondaryPort, bool useSecondaryDirectory);
@@ -44,7 +44,7 @@ namespace Tgstation.Server.Host.Components.Watchdog
Task OnReboot { get; }
/// <summary>
/// Releases the <see cref="ISession"/> without terminating it. Also calls <see cref="IDisposable.Dispose"/>
/// Releases the <see cref="ISession"/> without terminating it. Also calls <see cref="System.IDisposable.Dispose"/>
/// </summary>
/// <returns><see cref="ReattachInformation"/> which can be used to create a new <see cref="ISessionController"/> similar to this one</returns>
ReattachInformation Release();
@@ -52,20 +52,22 @@ namespace Tgstation.Server.Host.Components.Watchdog
/// <summary>
/// Sends a command to DreamDaemon through /world/Topic()
/// </summary>
/// <param name="cancellatonToken">The <see cref="CancellationToken"/> for the operation</param>
/// <param name="command">The command to send</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation</param>
/// <returns>A <see cref="Task{TResult}"/> resulting in the result of /world/Topic()</returns>
Task<string> SendCommand(string command, CancellationToken cancellationToken);
/// <summary>
/// Closes the world's port
/// </summary>
/// <param name="cancellatonToken">The <see cref="CancellationToken"/> for the operation</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation</param>
/// <returns>A <see cref="Task{TResult}"/> resulting in <see langword="true"/> if the operation succeeded, <see langword="false"/> otherwise</returns>
Task<bool> ClosePort(CancellationToken cancellationToken);
/// <summary>
/// Causes the world to start listening on a <paramref name="newPort"/>
/// </summary>
/// <param name="newPort">The port to change to</param>
/// <param name="cancellatonToken">The <see cref="CancellationToken"/> for the operation</param>
/// <returns>A <see cref="Task{TResult}"/> resulting in <see langword="true"/> if the operation succeeded, <see langword="false"/> otherwise</returns>
Task<bool> SetPort(ushort newPort, CancellationToken cancellatonToken);
@@ -74,7 +76,7 @@ namespace Tgstation.Server.Host.Components.Watchdog
/// Attempts to change the current <see cref="RebootState"/> to <paramref name="newRebootState"/>
/// </summary>
/// <param name="newRebootState">The new <see cref="RebootState"/></param>
/// <param name="cancellatonToken">The <see cref="CancellationToken"/> for the operation</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation</param>
/// <returns>A <see cref="Task{TResult}"/> resulting in <see langword="true"/> if the operation succeeded, <see langword="false"/> otherwise</returns>
Task<bool> SetRebootState(RebootState newRebootState, CancellationToken cancellationToken);
}
@@ -9,7 +9,7 @@ namespace Tgstation.Server.Host.Components.Watchdog
public sealed class LaunchResult
{
/// <summary>
/// The time it took for <see cref="System.Diagnostics.Process.WaitForInputIdle"/> to return
/// The time it took for <see cref="System.Diagnostics.Process.WaitForInputIdle()"/> to return
/// </summary>
public TimeSpan StartupTime { get; set; }
@@ -12,7 +12,16 @@ namespace Tgstation.Server.Host.Components.Watchdog
/// </summary>
public IDmbProvider Dmb { get; set; }
/// <summary>
/// Construct a <see cref="ReattachInformation"/>
/// </summary>
public ReattachInformation() { }
/// <summary>
/// Construct a <see cref="ReattachInformation"/> from a given <paramref name="copy"/> and <paramref name="dmbFactory"/>
/// </summary>
/// <param name="copy">The <see cref="Models.ReattachInformation"/> to copy values from</param>
/// <param name="dmbFactory">The <see cref="IDmbFactory"/> used to assign <see cref="Dmb"/></param>
public ReattachInformation(Models.ReattachInformation copy, IDmbFactory dmbFactory) : base(copy)
{
Dmb = dmbFactory.FromCompileJob(copy.CompileJob);
@@ -177,7 +177,7 @@ namespace Tgstation.Server.Host.Components.Watchdog
{
logger.LogInformation("Monitor activation. Reason: {0}", activationReason);
await Task.Yield();
throw new NotImplementedException();
throw new NotImplementedException(nameof(monitorState));
}
/// <summary>
@@ -224,7 +224,7 @@ namespace Tgstation.Server.Host.Components.Watchdog
}
var chatTask = Task.CompletedTask;
using (await SemaphoreContext.Lock(semaphore, cancellationToken).ConfigureAwait(false))
using (await SemaphoreSlimContext.Lock(semaphore, cancellationToken).ConfigureAwait(false))
{
MonitorActivationReason activationReason = default;
//multiple things may have happened, handle them one at a time
@@ -276,7 +276,7 @@ namespace Tgstation.Server.Host.Components.Watchdog
for (var retryAttempts = 1; state.NextAction == MonitorAction.Restart; ++retryAttempts)
{
WatchdogLaunchResult result;
using (await SemaphoreContext.Lock(semaphore, cancellationToken).ConfigureAwait(false))
using (await SemaphoreSlimContext.Lock(semaphore, cancellationToken).ConfigureAwait(false))
result = await LaunchNoLock(false, false, false, cancellationToken).ConfigureAwait(false);
await chatTask.ConfigureAwait(false);
@@ -320,7 +320,7 @@ namespace Tgstation.Server.Host.Components.Watchdog
/// <inheritdoc />
public async Task ChangeSettings(DreamDaemonLaunchParameters launchParameters, CancellationToken cancellationToken)
{
using (await SemaphoreContext.Lock(semaphore, cancellationToken).ConfigureAwait(false))
using (await SemaphoreSlimContext.Lock(semaphore, cancellationToken).ConfigureAwait(false))
{
ActiveLaunchParameters = launchParameters;
if (Running)
@@ -462,21 +462,21 @@ namespace Tgstation.Server.Host.Components.Watchdog
/// <inheritdoc />
public async Task<WatchdogLaunchResult> Launch(CancellationToken cancellationToken)
{
using (await SemaphoreContext.Lock(semaphore, cancellationToken).ConfigureAwait(false))
using (await SemaphoreSlimContext.Lock(semaphore, cancellationToken).ConfigureAwait(false))
return await LaunchNoLock(true, true, false, cancellationToken).ConfigureAwait(false);
}
/// <inheritdoc />
public async Task<WatchdogLaunchResult> Restart(bool graceful, CancellationToken cancellationToken)
{
using (await SemaphoreContext.Lock(semaphore, cancellationToken).ConfigureAwait(false))
using (await SemaphoreSlimContext.Lock(semaphore, cancellationToken).ConfigureAwait(false))
return await RestartNoLock(graceful, cancellationToken).ConfigureAwait(false);
}
/// <inheritdoc />
public async Task Terminate(bool graceful, CancellationToken cancellationToken)
{
using (await SemaphoreContext.Lock(semaphore, cancellationToken).ConfigureAwait(false))
using (await SemaphoreSlimContext.Lock(semaphore, cancellationToken).ConfigureAwait(false))
await TerminateNoLock(graceful, true, cancellationToken).ConfigureAwait(false);
}
@@ -499,7 +499,7 @@ namespace Tgstation.Server.Host.Components.Watchdog
/// <inheritdoc />
public async Task HandleEvent(EventType eventType, IEnumerable<string> parameters, CancellationToken cancellationToken)
{
using (await SemaphoreContext.Lock(semaphore, cancellationToken).ConfigureAwait(false))
using (await SemaphoreSlimContext.Lock(semaphore, cancellationToken).ConfigureAwait(false))
{
if (!Running)
return;
@@ -1,6 +1,7 @@
using Microsoft.Extensions.Logging;
using System;
using Tgstation.Server.Api.Models.Internal;
using Tgstation.Server.Host.Components.Chat;
using Tgstation.Server.Host.Core;
namespace Tgstation.Server.Host.Components.Watchdog
@@ -36,7 +37,6 @@ namespace Tgstation.Server.Host.Components.Watchdog
/// <summary>
/// Construct a <see cref="WatchdogFactory"/>
/// </summary>
/// <param name="byond">The value of <see cref="byond"/></param>
/// <param name="chat">The value of <see cref="chat"/></param>
/// <param name="sessionManagerFactory">The value of <see cref="sessionManagerFactory"/></param>
/// <param name="serverUpdater">The value of <see cref="serverUpdater"/></param>
@@ -18,7 +18,16 @@ namespace Tgstation.Server.Host.Components.Watchdog
/// </summary>
public ReattachInformation Bravo { get; set; }
/// <summary>
/// Construct a <see cref="WatchdogReattachInformation"/>
/// </summary>
public WatchdogReattachInformation() { }
/// <summary>
/// Construct a <see cref="WatchdogReattachInformation"/> from a given <paramref name="copy"/> with a given <paramref name="dmbFactory"/>
/// </summary>
/// <param name="copy">The <see cref="WatchdogReattachInformationBase"/> to copy information from</param>
/// <param name="dmbFactory">The <see cref="IDmbFactory"/> used to build the <see cref="ReattachInformation.Dmb"/>s</param>
public WatchdogReattachInformation(Models.WatchdogReattachInformation copy, IDmbFactory dmbFactory): base(copy)
{
if (copy.Alpha != null)
@@ -7,7 +7,7 @@ namespace Tgstation.Server.Host.Core
/// <summary>
/// Async lock context helper
/// </summary>
public sealed class SemaphoreContext : IDisposable
public sealed class SemaphoreSlimContext : IDisposable
{
/// <summary>
/// Asyncronously locks a <paramref name="semaphore"/>
@@ -15,13 +15,13 @@ namespace Tgstation.Server.Host.Core
/// <param name="semaphore">The <see cref="SemaphoreSlim"/> to lock</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation</param>
/// <returns>A <see cref="Task{TResult}"/> resulting in the <see cref="SemaphoreSlimContext"/> for the lock</returns>
public static async Task<SemaphoreContext> Lock(SemaphoreSlim semaphore, CancellationToken cancellationToken)
public static async Task<SemaphoreSlimContext> Lock(SemaphoreSlim semaphore, CancellationToken cancellationToken)
{
if (semaphore == null)
throw new ArgumentNullException(nameof(semaphore));
await semaphore.WaitAsync(cancellationToken).ConfigureAwait(false);
cancellationToken.ThrowIfCancellationRequested();
return new SemaphoreContext(semaphore);
return new SemaphoreSlimContext(semaphore);
}
/// <summary>
@@ -38,12 +38,12 @@ namespace Tgstation.Server.Host.Core
/// Construct a <see cref="SemaphoreSlimContext"/>
/// </summary>
/// <param name="lockedSemaphore">The value of <see cref="lockedSemaphore"/></param>
SemaphoreContext(SemaphoreSlim lockedSemaphore) => this.lockedSemaphore = lockedSemaphore;
SemaphoreSlimContext(SemaphoreSlim lockedSemaphore) => this.lockedSemaphore = lockedSemaphore;
/// <summary>
/// Finalize the <see cref="SemaphoreSlimContext"/>
/// </summary>
~SemaphoreContext() => Dispose();
~SemaphoreSlimContext() => Dispose();
/// <summary>
/// Release the lock on <see cref="lockedSemaphore"/>
@@ -32,8 +32,13 @@ namespace Tgstation.Server.Host.Models
public Instance Instance { get; set; }
/// <summary>
/// See <see cref="Api.Models.DreamDaemon.CompileJob"/>
/// See <see cref="Api.Models.DreamDaemon.ActiveCompileJob"/>
/// </summary>
public CompileJob CompileJob { get; set; }
}
public CompileJob ActiveCompileJob { get; set; }
/// <summary>
/// See <see cref="Api.Models.DreamDaemon.StagedCompileJob"/>
/// </summary>
public CompileJob StagedCompileJob { get; set; }
}
}
@@ -7,7 +7,7 @@ namespace Tgstation.Server.Host.Models
/// <summary>
/// Base class for <see cref="ReattachInformation"/>
/// </summary>
public class ReattachInformationBase
public abstract class ReattachInformationBase
{
/// <summary>
/// Used to identify and authenticate the DreamDaemon instance
@@ -21,7 +21,7 @@ namespace Tgstation.Server.Host.Models
public int ProcessId { get; set; }
/// <summary>
/// If the <see cref="IDmbProvider.PrimaryDirectory"/> of <see cref="Dmb"/> is being used
/// If the <see cref="Components.IDmbProvider.PrimaryDirectory"/> of the associated dmb is being used
/// </summary>
public bool IsPrimary { get; set; }
@@ -48,8 +48,15 @@ namespace Tgstation.Server.Host.Models
[Required]
public string ChatChannelsJson { get; set; }
/// <summary>
/// Construct a <see cref="ReattachInformationBase"/>
/// </summary>
public ReattachInformationBase() { }
/// <summary>
/// Construct a <see cref="ReattachInformationBase"/> from a given <paramref name="copy"/>
/// </summary>
/// <param name="copy">The <see cref="ReattachInformationBase"/> to copy values from</param>
protected ReattachInformationBase(ReattachInformationBase copy)
{
if (copy == null)
@@ -2,14 +2,25 @@
namespace Tgstation.Server.Host.Models
{
public class WatchdogReattachInformationBase
/// <summary>
/// Base class for <see cref="WatchdogReattachInformation"/>
/// </summary>
public abstract class WatchdogReattachInformationBase
{
/// <summary>
/// If the Alpha session is the active session
/// </summary>
public bool AlphaIsActive { get; set; }
/// <summary>
/// Construct a <see cref="WatchdogReattachInformationBase"/>
/// </summary>
public WatchdogReattachInformationBase() { }
/// <summary>
/// Construct a <see cref="WatchdogReattachInformation"/> from a given <paramref name="copy"/>
/// </summary>
/// <param name="copy">The <see cref="WatchdogReattachInformationBase"/> to copy values from</param>
protected WatchdogReattachInformationBase(WatchdogReattachInformationBase copy)
{
AlphaIsActive = copy?.AlphaIsActive ?? throw new ArgumentNullException(nameof(copy));