2017-01-04 09:27:36 +00:00
|
|
|
package conf
|
|
|
|
|
|
|
|
import (
|
|
|
|
"path"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
client "github.com/coreos/etcd/clientv3"
|
|
|
|
|
|
|
|
"sunteng/commons/confutil"
|
|
|
|
"sunteng/commons/log"
|
|
|
|
"sunteng/commons/util"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
Config = new(Conf)
|
|
|
|
)
|
|
|
|
|
|
|
|
func Init() error {
|
|
|
|
Config.Root = util.CurDir()
|
|
|
|
|
|
|
|
confFile := path.Join(Config.Root, "files", "base.json")
|
|
|
|
err := confutil.LoadExtendConf(confFile, Config)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
if Config.Etcd.DialTimeout > 0 {
|
|
|
|
Config.Etcd.DialTimeout *= time.Second
|
|
|
|
}
|
|
|
|
log.InitConf(&Config.Log)
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
type Conf struct {
|
|
|
|
Root string // 项目根目录
|
|
|
|
|
2017-01-05 02:37:48 +00:00
|
|
|
Proc string // proc 路径
|
|
|
|
Cmd string // cmd 路径
|
2017-01-06 08:44:42 +00:00
|
|
|
Sep string // etcd key 的连接符
|
2017-01-05 02:37:48 +00:00
|
|
|
|
2017-01-05 12:35:41 +00:00
|
|
|
Ttl int64 // 节点超时时间,单位秒
|
|
|
|
|
2017-01-04 09:27:36 +00:00
|
|
|
Log log.Config
|
|
|
|
Etcd client.Config
|
|
|
|
}
|