Extracted all TODO static values to configuration parameters
This commit is contained in:
@@ -21,6 +21,7 @@ public partial class Server
|
||||
var dockerClient = ServiceProvider.GetRequiredService<DockerClient>();
|
||||
|
||||
var parameters = Configuration.ToRuntimeCreateParameters(
|
||||
appConfiguration: AppConfiguration,
|
||||
hostPath: RuntimeVolumePath,
|
||||
containerName: RuntimeContainerName
|
||||
);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Docker.DotNet;
|
||||
using MoonlightServers.Daemon.Configuration;
|
||||
|
||||
namespace MoonlightServers.Daemon.Abstractions;
|
||||
|
||||
@@ -19,12 +20,11 @@ public partial class Server
|
||||
if (container.State.Running)
|
||||
{
|
||||
// Stop container when running
|
||||
|
||||
await LogToConsole("Stopping container");
|
||||
|
||||
|
||||
await dockerClient.Containers.StopContainerAsync(container.ID, new()
|
||||
{
|
||||
WaitBeforeKillSeconds = 30 // TODO: Config
|
||||
WaitBeforeKillSeconds = (uint)AppConfiguration.Server.WaitBeforeKillSeconds
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -50,6 +50,7 @@ public partial class Server
|
||||
|
||||
// Creating container configuration
|
||||
var parameters = Configuration.ToInstallationCreateParameters(
|
||||
appConfiguration: AppConfiguration,
|
||||
RuntimeVolumePath,
|
||||
InstallationVolumePath,
|
||||
InstallationContainerName,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Docker.DotNet.Models;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using MoonlightServers.Daemon.Configuration;
|
||||
using MoonlightServers.Daemon.Enums;
|
||||
using MoonlightServers.Daemon.Http.Hubs;
|
||||
using MoonlightServers.Daemon.Models;
|
||||
@@ -36,20 +37,23 @@ public partial class Server
|
||||
private StateMachine<ServerState, ServerTrigger> StateMachine;
|
||||
private ServerConfiguration Configuration;
|
||||
private CancellationTokenSource Cancellation;
|
||||
private AppConfiguration AppConfiguration;
|
||||
|
||||
public Server(
|
||||
ILogger logger,
|
||||
IServiceProvider serviceProvider,
|
||||
ServerConfiguration configuration,
|
||||
IHubContext<ServerWebSocketHub> webSocketHub
|
||||
IHubContext<ServerWebSocketHub> webSocketHub,
|
||||
AppConfiguration appConfiguration
|
||||
)
|
||||
{
|
||||
Logger = logger;
|
||||
ServiceProvider = serviceProvider;
|
||||
Configuration = configuration;
|
||||
WebSocketHub = webSocketHub;
|
||||
AppConfiguration = appConfiguration;
|
||||
|
||||
Console = new();
|
||||
Console = new(AppConfiguration.Server.ConsoleMessageCacheLimit);
|
||||
Cancellation = new();
|
||||
|
||||
RuntimeContainerName = $"moonlight-runtime-{Configuration.Id}";
|
||||
|
||||
Reference in New Issue
Block a user