-
Notifications
You must be signed in to change notification settings - Fork 2
/
Program.cs
68 lines (65 loc) · 2.62 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
58
59
60
61
62
63
64
65
66
67
68
using System;
using Duber.Domain.Driver.Persistence;
using Duber.Domain.User.Persistence;
using Duber.Infrastructure.WebHost;
using Duber.WebSite.Infrastructure.Persistence;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Configuration.AzureAppConfiguration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
namespace Duber.WebSite
{
public class Program
{
public static void Main(string[] args)
{
BuildWebHost(args)
.MigrateDbContext<UserContext>((context, services) =>
{
var logger = services.GetService<ILogger<UserContextSeed>>();
new UserContextSeed()
.SeedAsync(context, logger)
.Wait();
})
.MigrateDbContext<DriverContext>((context, services) =>
{
var logger = services.GetService<ILogger<DriverContextSeed>>();
new DriverContextSeed()
.SeedAsync(context, logger)
.Wait();
})
.MigrateDbContext<ReportingContext>((_, __) => { })
.Run();
}
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.UseApplicationInsights()
.ConfigureAppConfiguration((builderContext, config) =>
{
config.AddEnvironmentVariables();
var settings = config.Build();
if (settings.GetValue<bool>("UseAzureAppConfiguration"))
{
config.AddAzureAppConfiguration(options =>
{
options.Connect(settings["ConnectionStrings:AppConfig"])
.ConfigureRefresh(refresh =>
{
refresh.Register("GeneralChaosSetting:Sentinel", refreshAll: true);
refresh.SetCacheExpiration(TimeSpan.FromSeconds(1));
});
});
}
})
.ConfigureLogging((hostingContext, builder) =>
{
builder.AddConfiguration(hostingContext.Configuration.GetSection("Logging"));
builder.AddConsole();
builder.AddDebug();
})
.Build();
}
}