Started with adding container creation and a server state machine

This commit is contained in:
2024-12-26 21:09:22 +01:00
parent 9f8c1f6d24
commit 039db22207
12 changed files with 548 additions and 32 deletions

View File

@@ -1,7 +0,0 @@
namespace MoonlightServers.Daemon.Models;
public class Allocation
{
public string IpAddress { get; set; }
public int Port { get; set; }
}

View File

@@ -1,22 +1,30 @@
namespace MoonlightServers.Daemon.Models;
namespace MoonlightServers.Daemon.Models.Cache;
public class ServerData
public class ServerConfiguration
{
public int Id { get; set; }
public string StartupCommand { get; set; }
public string OnlineDetection { get; set; }
public string StopCommand { get; set; }
public string DockerImage { get; set; }
public bool PullDockerImage { get; set; }
public string ParseConiguration { get; set; }
// Limits
public int Cpu { get; set; }
public int Memory { get; set; }
public int Disk { get; set; }
public bool UseVirtualDisk { get; set; }
public int Bandwidth { get; set; }
public bool UseVirtualDisk { get; set; }
// Start, Stop & Status
public string StartupCommand { get; set; }
public string StopCommand { get; set; }
public string OnlineDetection { get; set; }
// Container
public string DockerImage { get; set; }
public AllocationConfiguration[] Allocations { get; set; }
public List<Allocation> Allocations { get; set; }
public Dictionary<string, string> Variables { get; set; }
public struct AllocationConfiguration
{
public string IpAddress { get; set; }
public int Port { get; set; }
}
}

View File

@@ -0,0 +1,12 @@
using MoonlightServers.Daemon.Helpers;
using MoonlightServers.Daemon.Models.Cache;
namespace MoonlightServers.Daemon.Models;
public class Server
{
public ServerState State => StateMachine.CurrentState;
public StateMachine<ServerState> StateMachine { get; set; }
public ServerConfiguration Configuration { get; set; }
public string? ContainerId { get; set; }
}

View File

@@ -0,0 +1,10 @@
namespace MoonlightServers.Daemon.Models;
public enum ServerState
{
Offline = 0,
Starting = 1,
Online = 2,
Stopping = 3,
Installing = 4
}

View File

@@ -0,0 +1,11 @@
namespace MoonlightServers.Daemon.Models;
public enum ServerTask
{
None = 0,
CreatingStorage = 1,
PullingDockerImage = 2,
RemovingContainer = 3,
CreatingContainer = 4,
StartingContainer = 5
}