diff --git a/core/constant/env.go b/core/constant/env.go index 66e078d7..e96660d6 100644 --- a/core/constant/env.go +++ b/core/constant/env.go @@ -38,4 +38,6 @@ const ( // EgoDefaultConfigExt defines default config file extension, support ".toml",".yaml",".json", // EgoDefaultConfigExt effective only the configuration file path without extension name EgoDefaultConfigExt = "EGO_DEFAULT_CONFIG_EXT" + // EgoDeploymentEnv defines deployment environment, such as "k8s", "ecs" + EgoDeploymentEnv = "EGO_DEPLOYMENT_ENV" ) diff --git a/server/server.go b/server/server.go index bbc2596c..77bd9980 100644 --- a/server/server.go +++ b/server/server.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "fmt" + "os" "reflect" "github.com/gotomicro/ego/core/constant" @@ -164,5 +165,6 @@ func defaultServiceInfo() ServiceInfo { si.Metadata["buildTime"] = eapp.BuildTime() si.Metadata["appVersion"] = eapp.AppVersion() si.Metadata["egoVersion"] = eapp.EgoVersion() + si.Metadata["depEnv"] = os.Getenv(constant.EgoDeploymentEnv) // 部署环境 return si } diff --git a/server/server_test.go b/server/server_test.go index c61a00d3..8445da78 100644 --- a/server/server_test.go +++ b/server/server_test.go @@ -43,6 +43,7 @@ func TestServiceInfo(t *testing.T) { "buildTime": "", "egoVersion": "unknown version", "key": "val", + "depEnv": "", "startTime": xtime.TS.Format(time.Now()), }, },