refactor: stats use address.yml

This commit is contained in:
710leo 2020-03-23 18:06:44 +08:00
parent 2b30d8e0bd
commit 408b6494d8
1 changed files with 5 additions and 5 deletions

View File

@ -21,14 +21,14 @@ var (
) )
func Init(prefix string, addr ...string) { func Init(prefix string, addr ...string) {
if len(addr) > 0 && addr[0] != "" {
//如果配置了 addr使用 addr 参数
PushUrl = addr[0]
if file.IsExist(path.Join(runner.Cwd, "etc", "address.yml")) { } else if file.IsExist(path.Join(runner.Cwd, "etc", "address.yml")) {
//address.yml 存在,使用配置文件的地址 //address.yml 存在,使用配置文件的地址
port := address.GetHTTPPort("collector") port := address.GetHTTPPort("collector")
PushUrl = fmt.Sprintf("http://127.0.0.1:%d/api/collector/push", port) PushUrl = fmt.Sprintf("http://127.0.0.1:%d/api/collector/push", port)
} else if len(addr) > 0 && addr[0] != "" {
// address.yml 不存在,使用 addr 参数
PushUrl = addr[0]
} }
Counter = NewCounter(prefix) Counter = NewCounter(prefix)