Skip to content

Commit

Permalink
Merge pull request #332 from liuhll/fix-hosting-env
Browse files Browse the repository at this point in the history
KestrelHost通过环境变量ASPNETCORE_ENVIRONMENT指定开发环境
  • Loading branch information
fanliang11 committed Jul 12, 2019
2 parents 9a0d2e1 + 78d7fb6 commit 7876ac6
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Surging.Core.CPlatform.Configurations
{
public enum RuntimeEnvironment
{
Development = 0,

Test,

Staging,

Production,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,7 @@ public partial class SurgingServerOptions: ServiceCommand
public string NotRelatedAssemblyFiles { get; set; }

public string RelatedAssemblyFiles { get; set; } = "";

public RuntimeEnvironment Environment { get; set; } = RuntimeEnvironment.Production;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public static IServiceHostBuilder UseServer(this IServiceHostBuilder hostBuilder
{
return hostBuilder.MapServices(async mapper =>
{
Environment.SetEnvironmentVariable("ASPNETCORE_ENVIRONMENT", AppConfig.ServerOptions.Environment.ToString());
BuildServiceEngine(mapper);
await mapper.Resolve<IServiceCommandManager>().SetServiceCommandsAsync();
string serviceToken = mapper.Resolve<IServiceTokenGenerator>().GeneratorToken(token);
Expand Down

0 comments on commit 7876ac6

Please sign in to comment.