-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathProgram.cs
57 lines (51 loc) · 1.98 KB
/
Program.cs
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
48
49
50
51
52
53
54
55
56
57
// ------------------------------------------------------------
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
// ------------------------------------------------------------
namespace MessageAnalyzer
{
using Dapr.Tests.Common;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using System;
using System.IO;
public class AppSettings {
public const string DaprHTTPAppPort = "DaprHTTPAppPort";
}
/// <summary>
/// MessageAnalyzer - receives messages from Dapr through pub/sub, adds a
/// sentiment, and sends them to an output binding.
/// </summary>
public class MessageAnalyzer
{
/// <summary>
/// Main for MessageAnalyzer.
/// </summary>
/// <param name="args">Arguments.</param>
public static void Main(string[] args)
{
ObservabilityUtils.StartMetricsServer();
CreateHostBuilder(args).Build().Run();
}
/// <summary>
/// Creates WebHost Builder.
/// </summary>
/// <param name="args">Arguments.</param>
/// <returns>Returns IHostbuilder.</returns>
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureTestInfraLogging()
.ConfigureWebHostDefaults(webBuilder =>
{
var appSettings = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile($"appsettings.json", optional: true, reloadOnChange: true)
.AddCommandLine(args)
.Build();
var host = webBuilder.UseStartup<Startup>()
.UseUrls(urls: $"http://*:{appSettings[AppSettings.DaprHTTPAppPort]}");
});
}
}