mirror of
https://github.com/fergalmoran/podnoms.git
synced 2025-12-22 09:18:08 +00:00
63 lines
2.5 KiB
C#
63 lines
2.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Net;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.AspNetCore;
|
|
using Microsoft.AspNetCore.Hosting;
|
|
using Microsoft.AspNetCore.Identity;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Logging;
|
|
using PodNoms.Api.Persistence;
|
|
using PodNoms.Api.Providers;
|
|
using PodNoms.Api.Services.Auth;
|
|
|
|
namespace PodNoms.Api {
|
|
public class Program {
|
|
static bool isDevelopment =
|
|
Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") == EnvironmentName.Development;
|
|
|
|
public static void Main(string[] args) {
|
|
var host = BuildWebHost(args);
|
|
using (var scope = host.Services.CreateScope()) {
|
|
var services = scope.ServiceProvider;
|
|
try {
|
|
SeedData.Initialize(services);
|
|
} catch (Exception ex) {
|
|
var logger = services.GetRequiredService<ILogger<Program>>();
|
|
logger.LogError(ex, "An error occurred seeding the DB.");
|
|
}
|
|
}
|
|
host.Run();
|
|
}
|
|
public static IWebHost BuildWebHost(string[] args) =>
|
|
WebHost.CreateDefaultBuilder(args)
|
|
.UseStartup<Startup>()
|
|
.UseUrls("http://0.0.0.0:5000")
|
|
.UseKestrel(options => {
|
|
options.Limits.MaxRequestBodySize = 1073741824;
|
|
}).Build();
|
|
|
|
}
|
|
}
|
|
|
|
/*
|
|
|
|
using (var scope = host.Services.CreateScope()) {
|
|
var services = scope.ServiceProvider;
|
|
try {
|
|
var context = services.GetRequiredService<PodNomsDbContext>();
|
|
var userManager = services.GetRequiredService<UserManager<ApplicationUser>>();
|
|
|
|
var dbInitializerLogger = services.GetRequiredService<ILogger<DbInitializer>>();
|
|
DbInitializer.Initialize(context, userManager, dbInitializerLogger).Wait();
|
|
} catch (Exception ex) {
|
|
var logger = services.GetRequiredService<ILogger<Program>>();
|
|
logger.LogError(ex, "An error occurred while seeding the database.");
|
|
}
|
|
host.MigrateDatabase((isDevelopment || migrate.ToUpper().Equals("TRUE")), drop != null && drop.Equals("TRUE"));
|
|
}
|
|
*/
|