-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathProgram.cs
53 lines (45 loc) · 1.65 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
using System;
using System.Text;
using System.Threading.Tasks;
using CryptoWatcher.Background;
using CryptoWatcher.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Spectre.Console;
namespace CryptoWatcher
{
public static class Program
{
public static async Task Main(string[] args)
{
using var host = CreateHostBuilder(args).Build();
Console.OutputEncoding = Encoding.UTF8;
Console.InputEncoding = Encoding.UTF8;
var rule = new Rule("₿ Crypto Watcher ₿");
AnsiConsole.Write(rule);
AnsiConsole.WriteLine();
await host.RunAsync();
}
private static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureLogging(logging =>
{
logging.ClearProviders();
})
.ConfigureServices(Configure)
.UseConsoleLifetime();
private static void Configure(HostBuilderContext context, IServiceCollection services)
{
var config = context.Configuration;
services.Configure<CryptoWatcherSettings>(config.GetSection("Watcher"), o => o.BindNonPublicProperties = true);
services.Configure<HostOptions>(option =>
{
// wait for graceful exit
option.ShutdownTimeout = TimeSpan.FromMinutes(1);
});
services.AddHostedService<RealtimePriceService>();
services.AddHostedService<OrderBookL3Service>();
}
}
}