Ver código fonte

根据 系统环境 读取不同的配置表

paddy 4 anos atrás
pai
commit
4bd44a2e7b
2 arquivos alterados com 12 adições e 4 exclusões
  1. 11 3
      config/config.go
  2. 1 1
      engine/apiengine.go

+ 11 - 3
config/config.go

@@ -1,6 +1,9 @@
 package config
 
-import "git.qianqiusoft.com/qianqiusoft/light-apiengine/logs"
+import (
+	"git.qianqiusoft.com/qianqiusoft/light-apiengine/logs"
+	"os"
+)
 
 type ApiConfig struct {
 	RunMode          string
@@ -24,9 +27,14 @@ func init() {
 
 func ParseConfig() {
 	var err error
-	_config, err = LoadConfiguration("conf/app.conf")
+	configPath := "conf/app.conf"
+	workEnv := os.Getenv("WORKENV")
+	if workEnv != "" {
+		configPath = "conf/app-" + workEnv + ".conf"
+	}
+	_config, err = LoadConfiguration(configPath)
 	if _config == nil {
-		panic("cant find config 'conf/app.conf'")
+		panic("cant find config '" + configPath + "'")
 	}
 	if err != nil {
 		logs.Error(err.Error())

+ 1 - 1
engine/apiengine.go

@@ -76,7 +76,7 @@ func NewApiEngine(driverName, dataSourceName string, addr string) *ApiEngine {
 	_, err = os.Stat("doc/api.tpl")
 	if err == nil {
 		fmt.Println("LoadHTMLGlob.")
-		engine.GinEngine.LoadHTMLGlob("doc/*")
+		engine.GinEngine.LoadHTMLGlob("doc/*.md")
 	}
 
 	//cross domain