Re-implemented server state machine. Cleaned up code

TODO: Handle trigger errors
This commit is contained in:
2025-02-12 23:02:00 +01:00
parent 4088bfaef5
commit f45699f300
44 changed files with 913 additions and 831 deletions

View File

@@ -0,0 +1,55 @@
using MoonCore.Helpers;
using MoonlightServers.Daemon.Configuration;
namespace MoonlightServers.Daemon.Abstractions;
public partial class Server
{
private async Task<string> EnsureRuntimeVolume()
{
var appConfiguration = ServiceProvider.GetRequiredService<AppConfiguration>();
var hostPath = PathBuilder.Dir(
appConfiguration.Storage.Volumes,
Configuration.Id.ToString()
);
await LogToConsole("Creating storage");
// TODO: Virtual disk
// Create volume if missing
if (!Directory.Exists(hostPath))
Directory.CreateDirectory(hostPath);
if (hostPath.StartsWith("/"))
return hostPath;
else
return PathBuilder.JoinPaths(Directory.GetCurrentDirectory(), hostPath);
return hostPath;
}
private async Task<string> EnsureInstallationVolume()
{
var appConfiguration = ServiceProvider.GetRequiredService<AppConfiguration>();
var hostPath = PathBuilder.Dir(
appConfiguration.Storage.Volumes,
Configuration.Id.ToString()
);
await LogToConsole("Creating storage");
// Create volume if missing
if (!Directory.Exists(hostPath))
Directory.CreateDirectory(hostPath);
if (hostPath.StartsWith("/"))
return hostPath;
else
return PathBuilder.JoinPaths(Directory.GetCurrentDirectory(), hostPath);
return hostPath;
}
}