-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathProgram.cs
53 lines (45 loc) · 1.86 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 FurlandGraph.Migrations;
using FurlandGraph.Models;
using Microsoft.EntityFrameworkCore;
using SimpleMigrations;
using SimpleMigrations.DatabaseProvider;
using FurlandGraph.Services;
using System.Net;
namespace FurlandGraph
{
public class Program
{
public static void Main(string[] args)
{
//ThreadPool.SetMaxThreads(2048, 2048);
//ThreadPool.SetMinThreads(256, 256);
ServicePointManager.DefaultConnectionLimit = int.MaxValue;
ServicePointManager.UseNagleAlgorithm = true;
var host = CreateHostBuilder(args).Build();
using (var serviceScope = host.Services.CreateScope())
{
var services = serviceScope.ServiceProvider;
// Run migrations
using var context = services.GetRequiredService<FurlandContext>();
var databaseProvider = new PostgresqlDatabaseProvider(context.Database.GetDbConnection());
var migrator = new SimpleMigrator(typeof(InitialCreate).Assembly, databaseProvider);
migrator.Load();
migrator.MigrateToLatest();
var databaseService = services.GetRequiredService<HarvestService>();
_ = Task.Run(databaseService.ParallelRun);
using (var serviceScope2 = host.Services.CreateScope())
{
var matrixService = serviceScope2.ServiceProvider.GetRequiredService<MatrixService>();
_ = Task.Run(matrixService.RunAsync);
host.Run();
}
}
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
}
}