sunty
2020-04-16 f689591ade2457d5fa707353c0b5959e6e486589
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
package config
 
import (
    "github.com/spf13/viper"
    "log"
)
 
const (
    StartServerScript = "seaweedfs_start.sh"
    StopServerScript  = "seaweedfs_stop.sh"
    //作为 volume 启动
    StartScriptAsVolume = "1"
    //作为 master 启动
    StartScriptAsMaster = "2"
    //作为 master + volume 启动
    StartScriptAsMaVo = "3"
    //启动项参数头
    Option = "option="
    //master列表项参数头
    Peer = "peers="
    //StartScriptAsFiler    = "option=4"
)
 
type server struct {
    EsServerIp   string `mapstructure: "esServerIp"`
    EsServerPort string `mapstructure: "esServerPort"`
    CoreBaseUnit string `mapstructure: "coreBaseUnit"`
    TimeOut      string `mapstructure: "timeOut"`
    ScriptPath   string `mapstructure: scriptPath`
}
 
type elastic struct {
    IndexName string `mapstructure: "indexName"`
    IndexType string `mapstructure: "indexType"`
}
 
var Server = &server{}
var BasicFS = &elastic{}
 
func Init(env string) {
    var err error
    viper.SetConfigType("yaml")
    viper.SetConfigName(env)
    viper.AddConfigPath("/opt/vasystem/config")
    err = viper.ReadInConfig()
    if err != nil {
        log.Fatal("error on parsing configuration file", err)
    }
    viper.UnmarshalKey("server", Server)
    viper.UnmarshalKey("elastic.basicFS", BasicFS)
    //fmt.Println(AiOcean)
    //fmt.Println(BasicFS)
}