Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shutdown endpoint #28

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion SS14.Watchdog/Controllers/InstanceController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using Microsoft.AspNetCore.Mvc;
using SS14.Watchdog.Components.ServerManagement;
using SS14.Watchdog.Utility;
using SIOFile = System.IO.File;

namespace SS14.Watchdog.Controllers
{
Expand Down Expand Up @@ -42,6 +41,19 @@ public async Task<IActionResult> Stop([FromHeader(Name = "Authorization")] strin
return Ok();
}

[HttpPost("shutdown")]
public async Task<IActionResult> Shutdown([FromHeader(Name = "Authorization")] string authorization, string key)
{
if (!TryAuthorize(authorization, key, out var failure, out var instance))
{
return failure;
}

await instance.DoStopCommandAsync(new ServerInstanceStopCommand());
await instance.ForceShutdownServerAsync();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can't just call this function from the API handler. You need to post a message into the actor queue like DoStopCommandAsync does. And make it a new command that properly sets the stopped flag so you don't need a separate DoStopCommandAsync call.

return Ok();
}

[HttpPost("update")]
public IActionResult Update([FromHeader(Name = "Authorization")] string authorization, string key)
{
Expand Down
Loading