From b6cb0a0bd8998ab5ef4436d50f1e0133960fb2aa Mon Sep 17 00:00:00 2001 From: Vasilis The Pikachu Date: Thu, 9 May 2024 23:56:33 +0200 Subject: [PATCH] Shutdown endpoint For the types you need to just kill the server now --- SS14.Watchdog/Controllers/InstanceController.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/SS14.Watchdog/Controllers/InstanceController.cs b/SS14.Watchdog/Controllers/InstanceController.cs index 3a2356b..7853c8c 100644 --- a/SS14.Watchdog/Controllers/InstanceController.cs +++ b/SS14.Watchdog/Controllers/InstanceController.cs @@ -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 { @@ -42,6 +41,19 @@ public async Task Stop([FromHeader(Name = "Authorization")] strin return Ok(); } + [HttpPost("shutdown")] + public async Task 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(); + return Ok(); + } + [HttpPost("update")] public IActionResult Update([FromHeader(Name = "Authorization")] string authorization, string key) {