| | |
| | | "flag" |
| | | "fmt" |
| | | "github.com/gin-gonic/gin" |
| | | "log" |
| | | "os" |
| | | "srm/core/internal" |
| | | |
| | |
| | | fmt.Println(err) |
| | | } |
| | | |
| | | ConfigFromEnv() |
| | | return v |
| | | } |
| | | |
| | | func ConfigFromEnv() { |
| | | DBHost := os.Getenv("DB_HOST") |
| | | DBName := os.Getenv("DB_NAME") |
| | | DBPort := os.Getenv("DB_PORT") |
| | | DBUser := os.Getenv("DB_USER") |
| | | DBPasswd := os.Getenv("DB_PASSWD") |
| | | if len(DBHost) > 0 && |
| | | len(DBName) > 0 && |
| | | len(DBPort) > 0 && |
| | | len(DBUser) > 0 && |
| | | len(DBPasswd) > 0 { |
| | | global.GVA_CONFIG.Mysql.Path = DBHost |
| | | global.GVA_CONFIG.Mysql.Port = DBPort |
| | | global.GVA_CONFIG.Mysql.Dbname = DBName |
| | | global.GVA_CONFIG.Mysql.Username = DBUser |
| | | global.GVA_CONFIG.Mysql.Password = DBPasswd |
| | | } |
| | | log.Printf("mysql dsn:%v", global.GVA_CONFIG.Mysql.Dsn()) |
| | | |
| | | grpcPort := os.Getenv("GRPC_PORT") |
| | | if grpcPort != "" { |
| | | global.GVA_CONFIG.System.GrpcPort = grpcPort |
| | | } |
| | | |
| | | apsGrpc := os.Getenv("APS_GRPC") |
| | | if apsGrpc != "" { |
| | | global.GVA_CONFIG.System.GrpcUrl = apsGrpc |
| | | } |
| | | |
| | | wmsGrpc := os.Getenv("WMS_GRPC") |
| | | if wmsGrpc != "" { |
| | | global.GVA_CONFIG.System.GrpcWmsUrl = wmsGrpc |
| | | } |
| | | |
| | | adminGrpc := os.Getenv("ADMIN_GRPC") |
| | | if adminGrpc != "" { |
| | | global.GVA_CONFIG.System.GrpcAdminUrl = adminGrpc |
| | | } |
| | | log.Printf(" System: %+v", global.GVA_CONFIG.System) |
| | | } |