修改环境
parent
25d07ecf8b
commit
6451f15ed6
|
@ -19,22 +19,33 @@ namespace IRaCIS.Core.API
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var index = Array.IndexOf(args, "--env");
|
//以配置文件为准,否则 从url中取环境值(服务以命令行传递参数启动,配置文件配置了就不需要传递环境参数)
|
||||||
var environment = index > -1
|
var config = new ConfigurationBuilder()
|
||||||
? args[index + 1]
|
.AddEnvironmentVariables()
|
||||||
: "Development";
|
.Build();
|
||||||
|
|
||||||
|
var enviromentName = config["ASPNETCORE_ENVIRONMENT"];
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(enviromentName))
|
||||||
|
{
|
||||||
|
|
||||||
|
var index = Array.IndexOf(args, "--env");
|
||||||
|
enviromentName = index > -1
|
||||||
|
? args[index + 1]
|
||||||
|
: "Development";
|
||||||
|
}
|
||||||
|
|
||||||
//Dicom 浏览
|
//Dicom 浏览
|
||||||
//ImageManager.SetImplementation(WinFormsImageManager.Instance);
|
//ImageManager.SetImplementation(WinFormsImageManager.Instance);
|
||||||
|
|
||||||
var host = CreateHostBuilder(args)
|
var host = CreateHostBuilder(args)
|
||||||
.UseEnvironment(environment) //命令行传入环境
|
.UseEnvironment(enviromentName) //命令行传入环境
|
||||||
.ConfigureAppConfiguration((hostContext, config) =>
|
.ConfigureAppConfiguration((hostContext, config) =>
|
||||||
{
|
{
|
||||||
|
|
||||||
//Console.WriteLine(hostContext.HostingEnvironment.EnvironmentName);
|
//Console.WriteLine(hostContext.HostingEnvironment.EnvironmentName);
|
||||||
config.AddJsonFile("appsettings.json", false, true)
|
config.AddJsonFile("appsettings.json", false, true)
|
||||||
.AddJsonFile($"appsettings.{environment}.json", false, true);
|
.AddJsonFile($"appsettings.{enviromentName}.json", false, true);
|
||||||
})
|
})
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
|
@ -46,7 +57,7 @@ namespace IRaCIS.Core.API
|
||||||
|
|
||||||
|
|
||||||
//// Serilog
|
//// Serilog
|
||||||
SerilogExtension.AddSerilogSetup(environment, host.Services);
|
SerilogExtension.AddSerilogSetup(enviromentName, host.Services);
|
||||||
|
|
||||||
//缓存项目的状态 匿名化数据
|
//缓存项目的状态 匿名化数据
|
||||||
await InitCache(host);
|
await InitCache(host);
|
||||||
|
@ -55,7 +66,7 @@ namespace IRaCIS.Core.API
|
||||||
|
|
||||||
host.Run();
|
host.Run();
|
||||||
|
|
||||||
Log.Logger.Warning($"当前环境:{environment}");
|
Log.Logger.Warning($"当前环境:{enviromentName}");
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
|
Loading…
Reference in New Issue