mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-29 16:11:05 +01:00
Merge pull request #665 from tgstation/663-SoftRestartNonsense [NugetDeploy]
Adds restart endpoint
This commit is contained in:
+6
-3
@@ -24,7 +24,6 @@ Last off, if anything in this API doesn't seem to hold true when tested against
|
||||
This document will reference the canonical C# models in the @ref Tgstation.Server.Api.Models namespace. Note that these models are built to mirror the JSON requests and responses with a couple caveats.
|
||||
|
||||
- The first letter of every field name will/must be lowercase in JSON models
|
||||
- Fields in the C# model marked with "DenyWrite = true" cannot be changed using POST requests
|
||||
- Fields marked 'Required' should be ignored, this is a semantic for the backing SQL database
|
||||
- Id fields must be specified when making POST requests
|
||||
- All other fields are optional and may be absent from responses or requests unless otherwise specified
|
||||
@@ -37,7 +36,7 @@ TGS4 expects this set of headers. Failure to provide them may result in 400 erro
|
||||
- Accept: application/json
|
||||
- Api: Another product header value representing the version of the API to use. Currently this must be: Tgstation.Server.Api/4.0.0.0
|
||||
|
||||
For POST and PUT requests you must also include the content type. Currently only json is supported
|
||||
For POST, PATCH, and PUT requests you must also include the content type. Currently only json is supported
|
||||
|
||||
- Content-Type: application/json
|
||||
|
||||
@@ -448,7 +447,11 @@ To start the watchdog use the following request:
|
||||
|
||||
I PUT "/DreamDaemon" Empty => @ref Tgstation.Server.Api.Models.Job
|
||||
|
||||
The returned job represents the startup process for the watchdog
|
||||
To restart the watchdog use the following request:
|
||||
|
||||
I PATCH "/DreamDaemon" Empty => @ref Tgstation.Server.Api.Models.Job
|
||||
|
||||
The returned jobs represents the startup process for the watchdog
|
||||
|
||||
To stop the watchdog use the following request:
|
||||
|
||||
|
||||
@@ -216,6 +216,9 @@ namespace Tgstation.Server.Client
|
||||
/// <inheritdoc />
|
||||
public Task<TResult> Create<TResult>(string route, long instanceId, CancellationToken cancellationToken) => RunRequest<TResult>(route, new object(), HttpMethod.Put, instanceId, cancellationToken);
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task<TResult> Patch<TResult>(string route, long instanceId, CancellationToken cancellationToken) => RunRequest<TResult>(route, new object(), new HttpMethod("PATCH"), instanceId, cancellationToken);
|
||||
|
||||
/// <inheritdoc />
|
||||
public void AddRequestLogger(IRequestLogger requestLogger) => requestLoggers.Add(requestLogger ?? throw new ArgumentNullException(nameof(requestLogger)));
|
||||
}
|
||||
|
||||
@@ -35,6 +35,9 @@ namespace Tgstation.Server.Client.Components
|
||||
/// <inheritdoc />
|
||||
public Task<Job> Start(CancellationToken cancellationToken) => apiClient.Create<Job>(Routes.DreamDaemon, instance.Id, cancellationToken);
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task<Job> Restart(CancellationToken cancellationToken) => apiClient.Patch<Job>(Routes.DreamDaemon, instance.Id, cancellationToken);
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task<DreamDaemon> Read(CancellationToken cancellationToken) => apiClient.Read<DreamDaemon>(Routes.DreamDaemon, instance.Id, cancellationToken);
|
||||
|
||||
|
||||
@@ -20,9 +20,16 @@ namespace Tgstation.Server.Client.Components
|
||||
/// Start <see cref="DreamDaemon"/>
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation</param>
|
||||
/// <returns>A <see cref="Task{TResult}"/> resulting in the <see cref="DreamDaemon"/> information</returns>
|
||||
/// <returns>A <see cref="Task{TResult}"/> resulting in the <see cref="Job"/> of the running operation</returns>
|
||||
Task<Job> Start(CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Restart <see cref="DreamDaemon"/>
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation</param>
|
||||
/// <returns>A <see cref="Task{TResult}"/> resulting in the <see cref="Job"/> of the running operation</returns>
|
||||
Task<Job> Restart(CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Shutdown <see cref="DreamDaemon"/>
|
||||
/// </summary>
|
||||
|
||||
@@ -32,6 +32,7 @@ namespace Tgstation.Server.Client
|
||||
|
||||
Task<TResult> Create<TBody, TResult>(string route, TBody body, long instanceId, CancellationToken cancellationToken);
|
||||
Task<TResult> Create<TResult>(string route, long instanceId, CancellationToken cancellationToken);
|
||||
Task<TResult> Patch<TResult>(string route, long instanceId, CancellationToken cancellationToken);
|
||||
Task<TResult> Read<TResult>(string route, long instanceId, CancellationToken cancellationToken);
|
||||
Task<TResult> Update<TBody, TResult>(string route, TBody body, long instanceId, CancellationToken cancellationToken);
|
||||
Task Delete(string route, long instanceId, CancellationToken cancellationToken);
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<DebugType>Full</DebugType>
|
||||
<Version>4.0.0.0-preview9108</Version>
|
||||
<Version>4.0.0.0-preview9109</Version>
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
<Authors>Cyberboss</Authors>
|
||||
<Company>/tg/station 13</Company>
|
||||
|
||||
@@ -209,5 +209,29 @@ namespace Tgstation.Server.Host.Controllers
|
||||
|
||||
return await ReadImpl(current, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handle a HTTP PATCH to the <see cref="DreamDaemonController"/>
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation</param>
|
||||
/// <returns>A <see cref="Task{TResult}"/> resulting in the <see cref="IActionResult"/> of the request</returns>
|
||||
[HttpPatch]
|
||||
[TgsAuthorize(DreamDaemonRights.Restart)]
|
||||
public async Task<IActionResult> Restart(CancellationToken cancellationToken)
|
||||
{
|
||||
var job = new Models.Job
|
||||
{
|
||||
Instance = Instance,
|
||||
CancelRightsType = RightsType.DreamDaemon,
|
||||
CancelRight = (ulong)DreamDaemonRights.Shutdown,
|
||||
StartedBy = AuthenticationContext.User,
|
||||
Description = "Restart Watchdog"
|
||||
};
|
||||
|
||||
var watchdog = instanceManager.GetInstance(Instance).Watchdog;
|
||||
|
||||
await jobManager.RegisterOperation(job, (paramJob, serviceProvider, progressReporter, ct) => watchdog.Restart(false, ct), cancellationToken).ConfigureAwait(false);
|
||||
return Accepted(job.ToApi());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user