Implemented server killing. Updated server manage ui. Added latest tailwind stuff. Added internal error handling
This commit is contained in:
28
MoonlightServers.Daemon/Abstractions/Server.Kill.cs
Normal file
28
MoonlightServers.Daemon/Abstractions/Server.Kill.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using Docker.DotNet;
|
||||
using MoonlightServers.Daemon.Enums;
|
||||
|
||||
namespace MoonlightServers.Daemon.Abstractions;
|
||||
|
||||
public partial class Server
|
||||
{
|
||||
public async Task Kill() => await StateMachine.FireAsync(ServerTrigger.Kill);
|
||||
|
||||
private async Task InternalKill()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (RuntimeContainerId == null)
|
||||
return;
|
||||
|
||||
await LogToConsole("Killing container");
|
||||
|
||||
var dockerClient = ServiceProvider.GetRequiredService<DockerClient>();
|
||||
await dockerClient.Containers.KillContainerAsync(RuntimeContainerId, new());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError("An error occured while performing stop trigger: {e}", e);
|
||||
await StateMachine.FireAsync(ServerTrigger.NotifyInternalError);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user