Skip to content

Commit

Permalink
PR comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
asherw committed Jul 11, 2020
1 parent 7d6ed0d commit 9bda4fa
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions src/DaemonRunner/DaemonRunner/Service/Runner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,9 @@ public static async Task Run(string[] args)
if (File.Exists(_hassioConfigPath))
await ReadHassioConfig();

await Host.CreateDefaultBuilder(args)
.UseSerilog(Log.Logger)
.ConfigureServices((context, services) =>
{
services.Configure<HomeAssistantSettings>(context.Configuration.GetSection("HomeAssistant"));
services.Configure<NetDaemonSettings>(context.Configuration.GetSection("NetDaemon"));
services.AddNetDaemon();
})
.Build()
.RunAsync();
var netDaemon = UseNetDaemon(args);

await netDaemon.Build().RunAsync();
}
catch (Exception e)
{
Expand All @@ -47,6 +38,19 @@ await Host.CreateDefaultBuilder(args)
}
}

public static IHostBuilder UseNetDaemon(string[] args)
{
return Host.CreateDefaultBuilder(args)
.UseSerilog(Log.Logger)
.ConfigureServices((context, services) =>
{
services.Configure<HomeAssistantSettings>(context.Configuration.GetSection("HomeAssistant"));
services.Configure<NetDaemonSettings>(context.Configuration.GetSection("NetDaemon"));
services.AddNetDaemon();
});
}

private static async Task ReadHassioConfig()
{
// https://docs.microsoft.com/en-us/aspnet/core/fundamentals/configuration/?view=aspnetcore-3.1#environment-variables
Expand Down

0 comments on commit 9bda4fa

Please sign in to comment.