Recreated plugin with new project template. Started implementing server system daemon

This commit is contained in:
2026-03-01 21:09:29 +01:00
parent f6b71f4de6
commit 52dbd13fb5
350 changed files with 2795 additions and 21553 deletions

View File

@@ -1,28 +0,0 @@
namespace MoonlightServers.Daemon.Models.Cache;
public class ServerConfiguration
{
public int Id { get; set; }
// Limits
public int Cpu { get; set; }
public int Memory { get; set; }
public int Disk { 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 Dictionary<string, string> Variables { get; set; }
public struct AllocationConfiguration
{
public string IpAddress { get; set; }
public int Port { get; set; }
}
}

View File

@@ -1,8 +0,0 @@
namespace MoonlightServers.Daemon.Models;
public class CpuUsageDetails
{
public string Model { get; set; }
public double OverallUsage { get; set; }
public double[] PerCoreUsage { get; set; }
}

View File

@@ -1,11 +0,0 @@
namespace MoonlightServers.Daemon.Models;
public class DiskUsageDetails
{
public string Device { get; set; }
public string MountPath { get; set; }
public ulong DiskTotal { get; set; }
public ulong DiskFree { get; set; }
public ulong InodesTotal { get; set; }
public ulong InodesFree { get; set; }
}

View File

@@ -0,0 +1,3 @@
namespace MoonlightServers.Daemon.Models;
public record InstallConfiguration(string Shell, string DockerImage, string Script);

View File

@@ -1,11 +0,0 @@
namespace MoonlightServers.Daemon.Models;
public class MemoryUsageDetails
{
public long Total { get; set; }
public long Available { get; set; }
public long Free { get; set; }
public long Cached { get; set; }
public long SwapTotal { get; set; }
public long SwapFree { get; set; }
}

View File

@@ -0,0 +1,47 @@
namespace MoonlightServers.Daemon.Models;
public record RuntimeConfiguration(
RuntimeLimitsConfig Limits,
RuntimeStorageConfig Storage,
RuntimeTemplateConfig Template,
RuntimeNetworkConfig Network,
RuntimeEnvironmentConfig Environment
);
public record RuntimeLimitsConfig(
int? CpuPercent,
int? Threads,
int? MemoryMb,
int? SwapMb
);
public record RuntimeStorageConfig(
string Provider,
Dictionary<string, string> Options,
int LimitMb
);
public record RuntimeTemplateConfig(
string DockerImage,
string StartupCommand,
string StopCommand,
string[] OnlineTexts
);
public record RuntimeNetworkConfig(
string[] Networks,
string? FriendlyName,
string? OutgoingIpAddress,
RuntimePortConfig? MainPort,
RuntimePortConfig[] Ports
);
public record RuntimePortConfig(
string IpAddress,
int Port
);
public record RuntimeEnvironmentConfig(
Dictionary<string, string> Labels,
Dictionary<string, string> Variables
);

View File

@@ -1,46 +0,0 @@
namespace MoonlightServers.Daemon.Models;
public class ServerConsole
{
public event Func<string, Task>? OnOutput;
public event Func<string, Task>? OnInput;
public string[] Messages => GetMessages();
private readonly Queue<string> MessageCache = new();
private int MaxMessagesInCache;
public ServerConsole(int maxMessagesInCache)
{
MaxMessagesInCache = maxMessagesInCache;
}
public async Task WriteToOutputAsync(string content)
{
lock (MessageCache)
{
MessageCache.Enqueue(content);
if (MessageCache.Count > MaxMessagesInCache)
MessageCache.Dequeue();
}
if (OnOutput != null)
{
await OnOutput
.Invoke(content)
.ConfigureAwait(ConfigureAwaitOptions.SuppressThrowing);
}
}
public async Task WriteToInputAsync(string content)
{
if (OnInput != null)
await OnInput.Invoke(content);
}
private string[] GetMessages()
{
lock (MessageCache)
return MessageCache.ToArray();
}
}

View File

@@ -1,75 +0,0 @@
using System.Text.Json.Serialization;
namespace MoonlightServers.Daemon.Models.UnsafeDocker;
public class DataUsageResponse
{
[JsonPropertyName("BuildCache")]
public BuildCacheData[] BuildCache { get; set; }
[JsonPropertyName("LayersSize")]
public long LayersSize { get; set; }
[JsonPropertyName("Images")]
public ImageData[] Images { get; set; }
[JsonPropertyName("Containers")]
public ContainerData[] Containers { get; set; }
[JsonPropertyName("Volumes")]
public VolumeData[] Volumes { get; set; }
public class BuildCacheData
{
[JsonPropertyName("Size")]
public long Size { get; set; }
[JsonPropertyName("InUse")]
public bool InUse { get; set; }
}
public class ContainerData
{
[JsonPropertyName("Id")]
public string Id { get; set; }
[JsonPropertyName("SizeRw")]
public long SizeRw { get; set; }
[JsonPropertyName("SizeRootFs")]
public long SizeRootFs { get; set; }
}
public class ImageData
{
[JsonPropertyName("Containers")]
public long Containers { get; set; }
[JsonPropertyName("Id")]
public string Id { get; set; }
[JsonPropertyName("SharedSize")]
public long SharedSize { get; set; }
[JsonPropertyName("Size")]
public long Size { get; set; }
}
public class VolumeData
{
[JsonPropertyName("Name")]
public string Name { get; set; }
[JsonPropertyName("UsageData")]
public VolumeUsageData UsageData { get; set; }
}
public class VolumeUsageData
{
[JsonPropertyName("RefCount")]
public long RefCount { get; set; }
[JsonPropertyName("Size")]
public long Size { get; set; }
}
}

View File

@@ -1,7 +0,0 @@
namespace MoonlightServers.Daemon.Models.UnsafeDocker;
public class UsageData
{
public long Used { get; set; }
public long Reclaimable { get; set; }
}

View File

@@ -1,8 +0,0 @@
namespace MoonlightServers.Daemon.Models.UnsafeDocker;
public class UsageDataReport
{
public UsageData Containers { get; set; }
public UsageData Images { get; set; }
public UsageData BuildCache { get; set; }
}