Re-implemented server state machine. Cleaned up code
TODO: Handle trigger errors
This commit is contained in:
55
MoonlightServers.Daemon/Abstractions/Server.Storage.cs
Normal file
55
MoonlightServers.Daemon/Abstractions/Server.Storage.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user