feat(realms): StopServer function

This commit is contained in:
CyberL1 2024-05-27 09:54:19 +02:00
parent 7268cd0da7
commit 28e842b286
2 changed files with 12 additions and 9 deletions

View File

@ -329,15 +329,7 @@ namespace Minecraft_Realms_Emulator.Modes.Realms.Controllers
if (world == null) return NotFound("World not found"); if (world == null) return NotFound("World not found");
// Stop the server new DockerHelper(world).StopServer();
ProcessStartInfo serverProcessInfo = new();
serverProcessInfo.FileName = "docker";
serverProcessInfo.Arguments = $"container stop realm-server-{world.Id}";
Process serverProcess = new();
serverProcess.StartInfo = serverProcessInfo;
serverProcess.Start();
world.State = nameof(StateEnum.CLOSED); world.State = nameof(StateEnum.CLOSED);

View File

@ -29,6 +29,17 @@ namespace Minecraft_Realms_Emulator.Modes.Realms.Helpers
serverProcess.Start(); serverProcess.Start();
} }
public void StopServer() {
ProcessStartInfo serverProcessInfo = new();
serverProcessInfo.FileName = "docker";
serverProcessInfo.Arguments = $"container stop realm-server-{world.Id}";
Process serverProcess = new();
serverProcess.StartInfo = serverProcessInfo;
serverProcess.Start();
}
public void DeleteServer() public void DeleteServer()
{ {
ProcessStartInfo serverProcessInfo = new(); ProcessStartInfo serverProcessInfo = new();