Kaynağa Gözat

调整配置

jiantaoli 4 yıl önce
ebeveyn
işleme
4526afa9b8

+ 1 - 1
ads_handler.go

@@ -59,7 +59,7 @@ func setupLogger(logName string, logLevel log.Level) {
59 59
 }
60 60
 
61 61
 func adsHandler(c *gin.Context) {
62
-	setupLogger("log/ads.log", log.TraceLevel)
62
+	setupLogger(adslib.GetConf().LogPath+"/ads.log", log.TraceLevel)
63 63
 	c.Header("Content-Type", "application/json")
64 64
 
65 65
 	request := adslib.Request{}

+ 3 - 1
adslib/config.go

@@ -22,6 +22,8 @@ type SvrConf struct {
22 22
 	ActionWeight       ActionWeight                          `toml:"action_weight"`
23 23
 	CombinationActions map[string][]CombinationActionsConf   `toml:"combination_actions"`
24 24
 	SecretKey          string                                `toml:"secret_key"`
25
+	Ip2RegionFile      string                                `toml:"ip2region_file"`
26
+	LogPath            string                                `toml:"log_path"`
25 27
 }
26 28
 type FlogControlItem struct {
27 29
 	Percent  int `toml:"percent"`
@@ -46,7 +48,7 @@ var svrConf SvrConf
46 48
 var once sync.Once
47 49
 
48 50
 func GetConf() *SvrConf {
49
-	once.Do(func () {
51
+	once.Do(func() {
50 52
 		_, err := toml.DecodeFile("./conf/config.toml", &svrConf)
51 53
 		if err != nil {
52 54
 			panic(err)

+ 3 - 1
adslib/ip2region/ip2region_test.go

@@ -3,13 +3,15 @@ package ip2region
3 3
 import (
4 4
 	"fmt"
5 5
 	"github.com/lionsoul2014/ip2region/binding/golang/ip2region"
6
+	"miads/adslib"
6 7
 	"testing"
7 8
 )
8 9
 
9 10
 var r *ip2region.Ip2Region
11
+
10 12
 func init() {
11 13
 	var err error
12
-	r, err = ip2region.New("../../conf/ip2region.db")
14
+	r, err = ip2region.New(adslib.GetConf().Ip2RegionFile)
13 15
 	if err != nil {
14 16
 		fmt.Printf("%s", err)
15 17
 	}

Dosya farkı çok büyük olduğundan ihmal edildi
+ 2 - 0
conf/config.toml


BIN
conf/ip2region.db


Dosya farkı çok büyük olduğundan ihmal edildi
+ 5 - 2
main_test.go