Re-implemented server state machine. Cleaned up code
TODO: Handle trigger errors
This commit is contained in:
23
MoonlightServers.Daemon/Abstractions/Server.Start.cs
Normal file
23
MoonlightServers.Daemon/Abstractions/Server.Start.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using Docker.DotNet;
|
||||
using MoonlightServers.Daemon.Enums;
|
||||
|
||||
namespace MoonlightServers.Daemon.Abstractions;
|
||||
|
||||
public partial class Server
|
||||
{
|
||||
public async Task Start() => await StateMachine.FireAsync(ServerTrigger.Start);
|
||||
|
||||
private async Task InternalStart()
|
||||
{
|
||||
await ReCreate();
|
||||
|
||||
await LogToConsole("Starting container");
|
||||
|
||||
// We can disable the null check for the runtime container id, as we set it by calling ReCreate();
|
||||
await AttachConsole(RuntimeContainerId!);
|
||||
|
||||
// Start container
|
||||
var dockerClient = ServiceProvider.GetRequiredService<DockerClient>();
|
||||
await dockerClient.Containers.StartContainerAsync(RuntimeContainerId, new());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user