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,11 +20,14 @@ sdkdb = 8 | ||
| 20 | sdkprefix = wxapi:: | 20 | sdkprefix = wxapi:: |
| 21 | 21 | ||
| 22 | [log] | 22 | [log] |
| 23 | -path = /var/logs/apigame/ | 23 | +path = ./logs/ |
| 24 | maxlines = 1000000 | 24 | maxlines = 1000000 |
| 25 | maxdays = 1000 | 25 | maxdays = 1000 |
| 26 | rotate = true | 26 | rotate = true |
| 27 | dellogger = false | 27 | dellogger = false |
| 28 | level = 1 | 28 | level = 1 |
| 29 | 29 | ||
| 30 | +[conf] | ||
| 31 | +path = ./conf/bytes | ||
| 32 | + | ||
| 30 | include "/conf/local.conf" | 33 | include "/conf/local.conf" |
| 31 | \ No newline at end of file | 34 | \ No newline at end of file |
conf/pre.conf
| @@ -27,5 +27,7 @@ rotate = true | @@ -27,5 +27,7 @@ rotate = true | ||
| 27 | dellogger = false | 27 | dellogger = false |
| 28 | level = 8 | 28 | level = 8 |
| 29 | 29 | ||
| 30 | +[conf] | ||
| 31 | +path = /home/etc/apigame/bytes | ||
| 30 | 32 | ||
| 31 | include "conf/pre.conf" | 33 | include "conf/pre.conf" |
| 32 | \ No newline at end of file | 34 | \ No newline at end of file |
conf/prod.conf
| @@ -28,5 +28,7 @@ rotate = true | @@ -28,5 +28,7 @@ rotate = true | ||
| 28 | dellogger = false | 28 | dellogger = false |
| 29 | level = 5 | 29 | level = 5 |
| 30 | 30 | ||
| 31 | +[conf] | ||
| 32 | +path = /goexec/exec/apigame/bytes | ||
| 31 | 33 | ||
| 32 | include "conf/prod.conf" | 34 | include "conf/prod.conf" |
| 33 | \ No newline at end of file | 35 | \ No newline at end of file |
configs/external.go
| @@ -2,12 +2,14 @@ package configs | @@ -2,12 +2,14 @@ package configs | ||
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | "fmt" | 4 | "fmt" |
| 5 | + "github.com/astaxie/beego" | ||
| 5 | "reflect" | 6 | "reflect" |
| 6 | ) | 7 | ) |
| 7 | 8 | ||
| 8 | func Init() bool { | 9 | func Init() bool { |
| 9 | fmt.Println("configs Init") | 10 | fmt.Println("configs Init") |
| 10 | - Initial("./conf/bytes", "ID") | 11 | + conf, _ := beego.AppConfig.GetSection("conf") |
| 12 | + Initial(conf["path"], "ID") | ||
| 11 | 13 | ||
| 12 | //InitExt() | 14 | //InitExt() |
| 13 | return true | 15 | return true |
controllers/demo.go
| @@ -4,7 +4,6 @@ import ( | @@ -4,7 +4,6 @@ import ( | ||
| 4 | "apigame/configs" | 4 | "apigame/configs" |
| 5 | "apigame/models" | 5 | "apigame/models" |
| 6 | "apigame/service/code-msg" | 6 | "apigame/service/code-msg" |
| 7 | - "apigame/util/zjson" | ||
| 8 | "encoding/json" | 7 | "encoding/json" |
| 9 | "fmt" | 8 | "fmt" |
| 10 | ) | 9 | ) |
| @@ -49,7 +48,8 @@ func (c *DemoController) Demo() { | @@ -49,7 +48,8 @@ func (c *DemoController) Demo() { | ||
| 49 | // conf := dt.(*configs.AbTestCfg) | 48 | // conf := dt.(*configs.AbTestCfg) |
| 50 | // fmt.Println(conf) | 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 | c.RetRspCodeData(code_msg.RECODE_OK, rsp) | 55 | c.RetRspCodeData(code_msg.RECODE_OK, rsp) |