Skip to content

Commit

Permalink
closed #123 added configuration loaded from upload directory
Browse files Browse the repository at this point in the history
  • Loading branch information
almostengr committed Jan 22, 2025
1 parent 06a6dbc commit c902672
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions hplightshow/Almostengr.HpLightShow.Worker/Program.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,46 @@
using Almostengr.HpLightShow.Core.Common;
using Almostengr.HpLightShow.Core.Countdowns;
using Almostengr.HpLightShow.Worker;

var builder = Host.CreateApplicationBuilder(args);

builder.Services.AddHttpClient();

loadConfiguration(builder);

builder.Services.AddTransient<ICountdownService, CountdownService>();

// builder.Services.AddSingleton(typeof(ILogger<>), typeof(LoggingService<>));

builder.Services.AddHostedService<CountdownWorker>();
builder.Services.AddHostedService<FppMonitorWorker>();

var host = builder.Build();
host.Run();




void loadConfiguration(HostApplicationBuilder builder)
{
const string PROD = "prod";
string environment = PROD;

#if !RELEASE
environment = "devl";
#endif

builder.Configuration.Sources.Clear();

IConfiguration configuration = new ConfigurationBuilder()
.AddJsonFile(
(environment == PROD) ?
"/home/fpp/media/upload/appsettings.json" :
"appsettings.Development.json",
false,
false)
.Build();

// builder.Configuration.AddConfiguration(configuration);
builder.Services.AddSingleton(configuration.GetSection(nameof(HpLightShowAppSettings)));
}

0 comments on commit c902672

Please sign in to comment.