This commit is contained in:
david 2024-09-17 18:54:13 +08:00
parent aada90ea78
commit 59118cf8f2
2 changed files with 13 additions and 3 deletions

14
env/env.go vendored
View File

@ -5,7 +5,6 @@ import (
"strings" "strings"
"git.apinb.com/bsm-sdk/engine/types" "git.apinb.com/bsm-sdk/engine/types"
"git.apinb.com/bsm-sdk/engine/utils"
) )
var MeshEnv *types.MeshEnv = nil var MeshEnv *types.MeshEnv = nil
@ -15,7 +14,7 @@ func NewEnv() *types.MeshEnv {
if MeshEnv == nil { if MeshEnv == nil {
MeshEnv = &types.MeshEnv{ MeshEnv = &types.MeshEnv{
Workspace: GetEnvDefault("BlocksMesh_Workspace", "bsm"), Workspace: GetEnvDefault("BlocksMesh_Workspace", "bsm"),
Prefix: GetEnvDefault("BlocksMesh_Prefix", utils.GetCurrentPath()), Prefix: GetEnvDefault("BlocksMesh_Prefix", "/usr/local/bsm"),
JwtSecretKey: GetEnvDefault("BlocksMesh_JwtSecretKey", "Cblocksmesh2022C"), JwtSecretKey: GetEnvDefault("BlocksMesh_JwtSecretKey", "Cblocksmesh2022C"),
RuntimeMode: strings.ToLower(GetEnvDefault("BlocksMesh_RuntimeMode", "dev")), RuntimeMode: strings.ToLower(GetEnvDefault("BlocksMesh_RuntimeMode", "dev")),
} }
@ -23,6 +22,17 @@ func NewEnv() *types.MeshEnv {
return MeshEnv return MeshEnv
} }
// get system base env.
func NewBaseEnv() *types.MeshEnv {
if MeshEnv == nil {
MeshEnv = &types.MeshEnv{
Prefix: GetEnvDefault("BlocksMesh_Prefix", "/usr/local/bsm"),
RuntimeMode: strings.ToLower(GetEnvDefault("BlocksMesh_RuntimeMode", "dev")),
}
}
return MeshEnv
}
func GetEnvDefault(key string, def string) string { func GetEnvDefault(key string, def string) string {
value := os.Getenv(key) value := os.Getenv(key)
if value == "" { if value == "" {

2
go.mod
View File

@ -1,3 +1,3 @@
module git.apinb.com/bsm-sdk/engine module git.apinb.com/bsm-sdk/engine
go 1.22 go 1.23