-
Notifications
You must be signed in to change notification settings - Fork 1
/
server_conf_json.go
executable file
·85 lines (72 loc) · 2.62 KB
/
server_conf_json.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package conf
import (
"github.com/goinbox/gomisc"
)
var scJson serverConfJson
type logConfJson struct {
Level int `json:"level"`
MaxAsyncMsgNum int `json:"max_async_msg_num"`
MaxBufferNum int `json:"max_buffer_num"`
Bufsize int `json:"bufsize"`
BufferAutoFlushTimeIntervalSeconds int `json:"buffer_auto_flush_time_interval_seconds"`
}
type pprofConfJson struct {
OnlineEnableHost string `json:"online_enable_host"`
Port string `json:"port"`
}
type httpConfJson struct {
GoHttpHost string `json:"gohttp_host"`
GoHttpPort string `json:"gohttp_port"`
}
type redisConfJson struct {
Host string `json:"host"`
Pass string `json:"pass"`
Port string `json:"port"`
RWTimeoutSeconds int `json:"rw_timeout_seconds"`
PoolSize int `json:"pool_size"`
PoolKeepAliveIntervalSeconds int `json:"pool_keepalive_interval_seconds"`
PoolClientMaxIdleSeconds int `json:"pool_client_max_idle_seconds"`
}
type mysqlConfJson struct {
Host string `json:"host"`
User string `json:"user"`
Pass string `json:"pass"`
Port string `json:"port"`
Name string `json:"name"`
RWTimeoutSeconds int `json:"rw_timeout_seconds"`
PoolSize int `json:"pool_size"`
PoolClientMaxIdleSeconds int `json:"pool_client_max_idle_seconds"`
}
type mongoConfJson struct {
Host string `json:"host"`
User string `json:"user"`
Pass string `json:"pass"`
Port string `json:"port"`
Name string `json:"name"`
RWTimeoutSeconds int `json:"rw_timeout_seconds"`
PoolSize int `json:"pool_size"`
PoolClientMaxIdleSeconds int `json:"pool_client_max_idle_seconds"`
}
type serverConfJson struct {
PrjName string `json:"prj_name"`
IsDev bool `json:"is_dev"`
Idc string `json:"idc"`
Log logConfJson `json:"log"`
Pprof pprofConfJson `json:"pprof"`
ApiHttp httpConfJson `json:"api_http"`
Redis redisConfJson `json:"redis"`
Mysql mysqlConfJson `json:"mysql"`
Mongo mongoConfJson `json:"mongo"`
}
func initServerConfJson() error {
confRoot := PrjHome + "/conf"
err := gomisc.ParseJsonFile(confRoot+"/server/server_conf.json", &scJson)
if err != nil {
return err
}
err = gomisc.ParseJsonFile(confRoot+"/server_conf_rewrite.json", &scJson)
if err != nil {
return err
}
return nil
}