From 408b6494d86e3fbcd4b3f1594d458e59de236064 Mon Sep 17 00:00:00 2001 From: 710leo <710leo@gmail.com> Date: Mon, 23 Mar 2020 18:06:44 +0800 Subject: [PATCH] refactor: stats use address.yml --- src/toolkits/stats/init.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/toolkits/stats/init.go b/src/toolkits/stats/init.go index bf7dd36d..9b74917d 100644 --- a/src/toolkits/stats/init.go +++ b/src/toolkits/stats/init.go @@ -21,14 +21,14 @@ var ( ) 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")) { - //address.yml 存在,使用配置文件的地址 + } else if file.IsExist(path.Join(runner.Cwd, "etc", "address.yml")) { + //address.yml 存在,则使用配置文件的地址 port := address.GetHTTPPort("collector") 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) -- GitLab