37 lines
1.3 KiB
C#
37 lines
1.3 KiB
C#
using Autofac.Extensions.DependencyInjection;
|
|
using Microsoft.AspNetCore.Hosting;
|
|
|
|
namespace CompetitionAPI
|
|
{
|
|
public class Program
|
|
{
|
|
public static void Main(string[] args)
|
|
{
|
|
//log4net.Config.XmlConfigurator.Configure();
|
|
CreateHostBuilder(args).Build().Run();
|
|
}
|
|
|
|
public static IHostBuilder CreateHostBuilder(string[] args) =>
|
|
Host.CreateDefaultBuilder(args).UseServiceProviderFactory(new AutofacServiceProviderFactory())
|
|
.ConfigureWebHostDefaults(webBuilder =>
|
|
{
|
|
webBuilder.UseUrls("http://*:5002");
|
|
webBuilder.UseStartup<Startup>();
|
|
})
|
|
.ConfigureAppConfiguration((hostingContext, config) =>
|
|
{
|
|
var env = hostingContext.HostingEnvironment;
|
|
|
|
config.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
|
|
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true, reloadOnChange: true);
|
|
|
|
// 添加其他配置源,如环境变量、命令行参数等
|
|
config.AddEnvironmentVariables();
|
|
|
|
if (args != null)
|
|
{
|
|
config.AddCommandLine(args);
|
|
}
|
|
});
|
|
}
|
|
} |