package config
|
|
import (
|
"github.com/spf13/viper"
|
"log"
|
)
|
|
const (
|
StartServerScript = "seaweedfs_start.sh"
|
StopServerScript = "seaweedfs_stop.sh"
|
//作为 master 启动
|
StartScriptAsMaster = "1"
|
//作为 volume 启动
|
StartScriptAsVolume = "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)
|
}
|