Commit f1704d8fdcbd8f6ee34bea2ae6ac3e56b7d000a6
1 parent
74e1d4d3
Exists in
master
feat✨:配置管理
Showing
7 changed files
with
16 additions
and
5 deletions
Show diff stats
.gitignore
conf/local.conf
| ... | ... | @@ -20,11 +20,14 @@ sdkdb = 8 |
| 20 | 20 | sdkprefix = wxapi:: |
| 21 | 21 | |
| 22 | 22 | [log] |
| 23 | -path = /var/logs/apigame/ | |
| 23 | +path = ./logs/ | |
| 24 | 24 | maxlines = 1000000 |
| 25 | 25 | maxdays = 1000 |
| 26 | 26 | rotate = true |
| 27 | 27 | dellogger = false |
| 28 | 28 | level = 1 |
| 29 | 29 | |
| 30 | +[conf] | |
| 31 | +path = ./conf/bytes | |
| 32 | + | |
| 30 | 33 | include "/conf/local.conf" |
| 31 | 34 | \ No newline at end of file | ... | ... |
conf/pre.conf
conf/prod.conf
configs/external.go
| ... | ... | @@ -2,12 +2,14 @@ package configs |
| 2 | 2 | |
| 3 | 3 | import ( |
| 4 | 4 | "fmt" |
| 5 | + "github.com/astaxie/beego" | |
| 5 | 6 | "reflect" |
| 6 | 7 | ) |
| 7 | 8 | |
| 8 | 9 | func Init() bool { |
| 9 | 10 | fmt.Println("configs Init") |
| 10 | - Initial("./conf/bytes", "ID") | |
| 11 | + conf, _ := beego.AppConfig.GetSection("conf") | |
| 12 | + Initial(conf["path"], "ID") | |
| 11 | 13 | |
| 12 | 14 | //InitExt() |
| 13 | 15 | return true | ... | ... |
controllers/demo.go
| ... | ... | @@ -4,7 +4,6 @@ import ( |
| 4 | 4 | "apigame/configs" |
| 5 | 5 | "apigame/models" |
| 6 | 6 | "apigame/service/code-msg" |
| 7 | - "apigame/util/zjson" | |
| 8 | 7 | "encoding/json" |
| 9 | 8 | "fmt" |
| 10 | 9 | ) |
| ... | ... | @@ -49,7 +48,8 @@ func (c *DemoController) Demo() { |
| 49 | 48 | // conf := dt.(*configs.AbTestCfg) |
| 50 | 49 | // fmt.Println(conf) |
| 51 | 50 | //} |
| 52 | - fmt.Println("cs", zjson.Str(cs)) | |
| 51 | + //fmt.Println("cs", zjson.Str(cs)) | |
| 52 | + rsp.Data = cs | |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | c.RetRspCodeData(code_msg.RECODE_OK, rsp) | ... | ... |