diff --git a/MoonlightServers.ApiServer/Properties/launchSettings.json b/MoonlightServers.ApiServer/Properties/launchSettings.json index ad29068..41ffc3d 100644 --- a/MoonlightServers.ApiServer/Properties/launchSettings.json +++ b/MoonlightServers.ApiServer/Properties/launchSettings.json @@ -9,11 +9,10 @@ "applicationUrl": "http://localhost:5269", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development", - "MOONLIGHT_APP_PUBLICURL": "http://localhost:5269", + "MOONLIGHT_PUBLICURL": "http://localhost:5269", "HTTP_PROXY": "", "HTTPS_PROXY": "" - }, - "commandLineArgs": "--frontend-asset js/XtermBlazor.min.js --frontend-asset js/moonlightServers.js --frontend-asset js/addon-fit.js" + } } } } diff --git a/MoonlightServers.Daemon/MoonlightServers.Daemon.csproj b/MoonlightServers.Daemon/MoonlightServers.Daemon.csproj index 7261d5b..165daaf 100644 --- a/MoonlightServers.Daemon/MoonlightServers.Daemon.csproj +++ b/MoonlightServers.Daemon/MoonlightServers.Daemon.csproj @@ -9,8 +9,8 @@ - - + + diff --git a/MoonlightServers.Daemon/Startup.cs b/MoonlightServers.Daemon/Startup.cs index 38378fb..49a86b4 100644 --- a/MoonlightServers.Daemon/Startup.cs +++ b/MoonlightServers.Daemon/Startup.cs @@ -1,6 +1,7 @@ using System.Text.Json; using Docker.DotNet; using MoonCore.Configuration; +using MoonCore.EnvConfiguration; using MoonCore.Extended.Extensions; using MoonCore.Extensions; using MoonCore.Helpers; @@ -17,8 +18,6 @@ public class Startup // Configuration private AppConfiguration Configuration; - private ConfigurationService ConfigurationService; - private ConfigurationOptions ConfigurationOptions; // Logging private ILoggerProvider[] LoggerProviders; @@ -119,42 +118,31 @@ public class Startup #region Configurations - private Task SetupAppConfiguration() + private async Task SetupAppConfiguration() { - ConfigurationService = new ConfigurationService(); + var configurationBuilder = new ConfigurationBuilder(); + + // Ensure configuration file exists + var jsonFilePath = PathBuilder.File(Directory.GetCurrentDirectory(), "storage", "app.json"); - // Setup options - ConfigurationOptions = new ConfigurationOptions(); + if (!File.Exists(jsonFilePath)) + await File.WriteAllTextAsync(jsonFilePath, JsonSerializer.Serialize(new AppConfiguration())); - ConfigurationOptions.AddConfiguration("app"); - ConfigurationOptions.Path = PathBuilder.Dir("storage"); - ConfigurationOptions.EnvironmentPrefix = "WebAppTemplate".ToUpper(); + configurationBuilder.AddJsonFile( + jsonFilePath + ); + + configurationBuilder.AddEnvironmentVariables(prefix: "MOONLIGHT_", separator: "_"); - // Create minimal logger - var loggerFactory = new LoggerFactory(); - - loggerFactory.AddMoonCore(configuration => - { - configuration.Console.Enable = true; - configuration.Console.EnableAnsiMode = true; - configuration.FileLogging.Enable = false; - }); - - var logger = loggerFactory.CreateLogger(); + var configurationRoot = configurationBuilder.Build(); // Retrieve configuration - Configuration = ConfigurationService.GetConfiguration( - ConfigurationOptions, - logger - ); - - return Task.CompletedTask; + Configuration = configurationRoot.Get()!; } private Task RegisterAppConfiguration() { - ConfigurationService.RegisterInDi(ConfigurationOptions, WebApplicationBuilder.Services); - WebApplicationBuilder.Services.AddSingleton(ConfigurationService); + WebApplicationBuilder.Services.AddSingleton(Configuration); return Task.CompletedTask; }