2017-08-29 12:03:20 +02:00
|
|
|
|
using Microsoft.AspNetCore;
|
2016-09-06 17:09:19 -07:00
|
|
|
|
using Microsoft.AspNetCore.Hosting;
|
2017-09-13 14:53:06 +02:00
|
|
|
|
using Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF;
|
|
|
|
|
using Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure;
|
2017-10-11 16:26:44 +02:00
|
|
|
|
using Microsoft.Extensions.Configuration;
|
2017-09-13 14:53:06 +02:00
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
2017-08-29 12:03:20 +02:00
|
|
|
|
using Microsoft.Extensions.Logging;
|
2017-09-13 14:53:06 +02:00
|
|
|
|
using Microsoft.Extensions.Options;
|
2017-02-23 09:34:00 -08:00
|
|
|
|
using System.IO;
|
2016-09-07 13:52:26 -07:00
|
|
|
|
namespace Microsoft.eShopOnContainers.Services.Catalog.API
|
2016-09-06 17:09:19 -07:00
|
|
|
|
{
|
|
|
|
|
public class Program
|
|
|
|
|
{
|
|
|
|
|
public static void Main(string[] args)
|
|
|
|
|
{
|
2017-09-13 14:53:06 +02:00
|
|
|
|
BuildWebHost(args)
|
|
|
|
|
.MigrateDbContext<CatalogContext>((context,services)=>
|
|
|
|
|
{
|
|
|
|
|
var env = services.GetService<IHostingEnvironment>();
|
|
|
|
|
var settings = services.GetService<IOptions<CatalogSettings>>();
|
|
|
|
|
var logger = services.GetService<ILogger<CatalogContextSeed>>();
|
|
|
|
|
|
|
|
|
|
new CatalogContextSeed()
|
|
|
|
|
.SeedAsync(context,env,settings,logger)
|
|
|
|
|
.Wait();
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
.MigrateDbContext<IntegrationEventLogContext>((_,__)=> { })
|
|
|
|
|
.Run();
|
2017-08-29 12:03:20 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static IWebHost BuildWebHost(string[] args) =>
|
|
|
|
|
WebHost.CreateDefaultBuilder(args)
|
|
|
|
|
.UseStartup<Startup>()
|
2017-03-23 19:10:55 +01:00
|
|
|
|
.UseHealthChecks("/hc")
|
2017-10-11 16:26:44 +02:00
|
|
|
|
.UseContentRoot(Directory.GetCurrentDirectory())
|
2016-12-29 15:25:36 +01:00
|
|
|
|
.UseWebRoot("Pics")
|
2017-10-11 16:26:44 +02:00
|
|
|
|
.ConfigureAppConfiguration((builderContext, config) =>
|
|
|
|
|
{
|
|
|
|
|
config.AddEnvironmentVariables();
|
|
|
|
|
})
|
2017-08-29 12:03:20 +02:00
|
|
|
|
.ConfigureLogging((hostingContext, builder) =>
|
|
|
|
|
{
|
|
|
|
|
builder.AddConfiguration(hostingContext.Configuration.GetSection("Logging"));
|
|
|
|
|
builder.AddConsole();
|
|
|
|
|
builder.AddDebug();
|
|
|
|
|
})
|
2017-10-11 16:26:44 +02:00
|
|
|
|
.UseApplicationInsights()
|
2017-08-29 12:03:20 +02:00
|
|
|
|
.Build();
|
2016-09-06 17:09:19 -07:00
|
|
|
|
}
|
2017-08-29 12:03:20 +02:00
|
|
|
|
}
|