Implemented installation handling. Added crash handling. Refactored tasks reset/cancel functions
This commit is contained in:
34
MoonlightServers.Daemon/Abstractions/Server.Crash.cs
Normal file
34
MoonlightServers.Daemon/Abstractions/Server.Crash.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using Docker.DotNet;
|
||||
using Docker.DotNet.Models;
|
||||
|
||||
namespace MoonlightServers.Daemon.Abstractions;
|
||||
|
||||
public partial class Server
|
||||
{
|
||||
public async Task InternalCrash()
|
||||
{
|
||||
var dockerClient = ServiceProvider.GetRequiredService<DockerClient>();
|
||||
|
||||
ContainerInspectResponse? container;
|
||||
|
||||
try
|
||||
{
|
||||
container = await dockerClient.Containers.InspectContainerAsync(RuntimeContainerId);
|
||||
}
|
||||
catch (DockerContainerNotFoundException)
|
||||
{
|
||||
container = null;
|
||||
}
|
||||
|
||||
if(container == null)
|
||||
return;
|
||||
|
||||
var exitCode = container.State.ExitCode;
|
||||
|
||||
// TODO: Report to panel
|
||||
|
||||
await LogToConsole($"Server crashed. Exit code: {exitCode}");
|
||||
|
||||
await Destroy();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user