-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
48 lines (38 loc) · 1.49 KB
/
Copy pathProgram.cs
File metadata and controls
48 lines (38 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
using hp_ssh_exporter.Model;
using hp_ssh_exporter.Service;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
var builder = new HostBuilder()
.ConfigureAppConfiguration((hostingContext, config) =>
{
config.AddEnvironmentVariables();
if (args != null)
{
config.AddCommandLine(args);
var tempConfig = config.Build();
var configFile = tempConfig.GetValue<string>("config");
config.AddJsonFile(configFile);
}
})
.ConfigureServices((hostContext, services) =>
{
services.AddOptions();
services.Configure<InfluxDbConfig>(hostContext.Configuration.GetSection("influxdb"));
services.Configure<SshLogScraperConfig>(hostContext.Configuration.GetSection("sshlogscraper"));
services.AddAutoMapper(config =>
{
config.CreateMap<IpApiData, MeasurementData>();
config.CreateMap<SshLogData, MeasurementData>();
});
services.AddTransient<InfluxdbClientService>();
services.AddSingleton<IpApiService>();
services.AddSingleton<IHostedService, SshLogScraperService>();
})
.ConfigureLogging((hostingContext, logging) =>
{
logging.AddConfiguration(hostingContext.Configuration.GetSection("Logging"));
logging.AddConsole();
});
await builder.RunConsoleAsync();