-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
closed #123 added configuration loaded from upload directory
- Loading branch information
almostengr
committed
Jan 22, 2025
1 parent
06a6dbc
commit c902672
Showing
1 changed file
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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))); | ||
} |