2020-03-22 14:18:34 +01:00
|
|
|
using Microsoft.AspNetCore.Hosting;
|
|
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
|
using Microsoft.Extensions.Hosting;
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
2020-03-22 14:29:12 +01:00
|
|
|
using System;
|
|
|
|
|
using System.Diagnostics;
|
2020-03-22 14:18:34 +01:00
|
|
|
|
2020-03-24 23:09:29 +01:00
|
|
|
namespace zero.Web
|
2020-03-22 14:18:34 +01:00
|
|
|
{
|
|
|
|
|
public class Program
|
|
|
|
|
{
|
|
|
|
|
public static void Main(string[] args)
|
|
|
|
|
{
|
2020-03-22 14:29:12 +01:00
|
|
|
Console.WriteLine("Process ID: " + Process.GetCurrentProcess().Id);
|
2020-03-22 14:18:34 +01:00
|
|
|
CreateHostBuilder(args).Build().Run();
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-22 14:29:12 +01:00
|
|
|
public static IHostBuilder CreateHostBuilder(string[] args)
|
|
|
|
|
{
|
|
|
|
|
return Host
|
|
|
|
|
.CreateDefaultBuilder(args)
|
2020-03-25 23:24:58 +01:00
|
|
|
.ConfigureAppConfiguration((context, config) =>
|
|
|
|
|
{
|
|
|
|
|
config.AddJsonFile("zeroSettings.json", optional: false, reloadOnChange: true);
|
|
|
|
|
config.AddJsonFile($"zeroSettings.{context.HostingEnvironment.EnvironmentName}.json", optional: true, reloadOnChange: true);
|
|
|
|
|
})
|
2020-03-22 14:29:12 +01:00
|
|
|
.ConfigureLogging((context, builder) =>
|
|
|
|
|
{
|
|
|
|
|
IConfigurationSection configuration = context.Configuration.GetSection("Logging");
|
|
|
|
|
builder.ClearProviders();
|
|
|
|
|
|
|
|
|
|
if (context.HostingEnvironment.IsDevelopment())
|
|
|
|
|
{
|
|
|
|
|
builder.AddConsole();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (configuration.GetValue("AsFile", false))
|
|
|
|
|
{
|
|
|
|
|
builder.AddFile(configuration);
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.ConfigureWebHostDefaults(webBuilder =>
|
|
|
|
|
{
|
|
|
|
|
webBuilder.UseStartup<Startup>();
|
|
|
|
|
});
|
|
|
|
|
}
|
2020-03-22 14:18:34 +01:00
|
|
|
}
|
|
|
|
|
}
|