Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
jobily
Nightingale
提交
46f7ec7a
N
Nightingale
项目概览
jobily
/
Nightingale
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
N
Nightingale
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
46f7ec7a
编写于
4月 15, 2021
作者:
7
710leo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
complete version information
上级
999c1b42
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
77 addition
and
43 deletion
+77
-43
src/modules/agentd/agentd.go
src/modules/agentd/agentd.go
+22
-1
src/modules/agentd/config/config.go
src/modules/agentd/config/config.go
+1
-17
src/modules/server/config/config.go
src/modules/server/config/config.go
+1
-20
src/modules/server/plugins/all/dlopen.go
src/modules/server/plugins/all/dlopen.go
+0
-4
src/modules/server/server.go
src/modules/server/server.go
+53
-1
未找到文件。
src/modules/agentd/agentd.go
浏览文件 @
46f7ec7a
...
...
@@ -24,6 +24,7 @@ import (
"github.com/didi/nightingale/v4/src/modules/agentd/timer"
"github.com/didi/nightingale/v4/src/modules/agentd/udp"
"github.com/toolkits/file"
"github.com/toolkits/pkg/logger"
"github.com/toolkits/pkg/runner"
)
...
...
@@ -58,6 +59,7 @@ func init() {
}
func
main
()
{
aconf
()
parseConf
()
loggeri
.
Init
(
config
.
Config
.
Logger
)
...
...
@@ -127,12 +129,31 @@ func monStart() {
}
func
parseConf
()
{
if
err
:=
config
.
Parse
();
err
!=
nil
{
if
err
:=
config
.
Parse
(
*
conf
);
err
!=
nil
{
fmt
.
Println
(
"cannot parse configuration file:"
,
err
)
os
.
Exit
(
1
)
}
}
func
aconf
()
{
if
*
conf
!=
""
&&
file
.
IsExist
(
*
conf
)
{
return
}
*
conf
=
"etc/agentd.local.yml"
if
file
.
IsExist
(
*
conf
)
{
return
}
*
conf
=
"etc/agentd.yml"
if
file
.
IsExist
(
*
conf
)
{
return
}
fmt
.
Println
(
"no configuration file for server"
)
os
.
Exit
(
1
)
}
func
endingProc
()
{
c
:=
make
(
chan
os
.
Signal
,
1
)
signal
.
Notify
(
c
,
syscall
.
SIGINT
,
syscall
.
SIGTERM
,
syscall
.
SIGQUIT
)
...
...
src/modules/agentd/config/config.go
浏览文件 @
46f7ec7a
...
...
@@ -82,9 +82,7 @@ var (
Endpoint
string
)
func
Parse
()
error
{
conf
:=
getYmlFile
()
func
Parse
(
conf
string
)
error
{
bs
,
err
:=
file
.
ReadBytes
(
conf
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"cannot read yml[%s]: %v"
,
conf
,
err
)
...
...
@@ -164,17 +162,3 @@ func Parse() error {
return
nil
}
func
getYmlFile
()
string
{
yml
:=
"etc/agentd.local.yml"
if
file
.
IsExist
(
yml
)
{
return
yml
}
yml
=
"etc/agentd.yml"
if
file
.
IsExist
(
yml
)
{
return
yml
}
return
""
}
src/modules/server/config/config.go
浏览文件 @
46f7ec7a
...
...
@@ -208,12 +208,7 @@ var Config *ConfigT
var
Ident
string
// Parse configuration file
func
Parse
()
error
{
ymlFile
:=
getYmlFile
()
if
ymlFile
==
""
{
return
fmt
.
Errorf
(
"configuration file etc/server.yml not found"
)
}
func
Parse
(
ymlFile
string
)
error
{
bs
,
err
:=
file
.
ReadBytes
(
ymlFile
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"cannot read yml[%s]: %v"
,
ymlFile
,
err
)
...
...
@@ -407,20 +402,6 @@ func Parse() error {
return
identity
.
Parse
()
}
func
getYmlFile
()
string
{
yml
:=
"etc/server.local.yml"
if
file
.
IsExist
(
yml
)
{
return
yml
}
yml
=
"etc/server.yml"
if
file
.
IsExist
(
yml
)
{
return
yml
}
return
""
}
// map["node"]="host1,host2" --> map["node"]=["host1", "host2"]
func
formatClusterItems
(
cluster
map
[
string
]
string
)
map
[
string
]
*
tsdb
.
ClusterNode
{
ret
:=
make
(
map
[
string
]
*
tsdb
.
ClusterNode
)
...
...
src/modules/server/plugins/all/dlopen.go
浏览文件 @
46f7ec7a
...
...
@@ -6,8 +6,6 @@ import (
"path/filepath"
"plugin"
"strings"
"github.com/toolkits/pkg/logger"
)
const
pluginDir
=
"plugins"
...
...
@@ -15,14 +13,12 @@ const pluginDir = "plugins"
func
init
()
{
plugins
,
err
:=
listPlugins
(
pluginDir
)
if
err
!=
nil
{
logger
.
Warningf
(
"list plugins: %s"
,
err
)
return
}
for
_
,
file
:=
range
plugins
{
_
,
err
:=
plugin
.
Open
(
file
)
if
err
!=
nil
{
logger
.
Warningf
(
"plugin.Open %s err %s"
,
file
,
err
)
continue
}
}
...
...
src/modules/server/server.go
浏览文件 @
46f7ec7a
package
main
import
(
"flag"
"fmt"
"log"
"os"
...
...
@@ -36,11 +37,43 @@ import (
_
"github.com/didi/nightingale/v4/src/modules/server/plugins/api"
_
"github.com/go-sql-driver/mysql"
"github.com/toolkits/file"
pcache
"github.com/toolkits/pkg/cache"
"github.com/toolkits/pkg/logger"
"github.com/toolkits/pkg/runner"
)
var
(
vers
*
bool
help
*
bool
conf
*
string
version
=
"No Version Provided"
)
func
init
()
{
vers
=
flag
.
Bool
(
"v"
,
false
,
"display the version."
)
help
=
flag
.
Bool
(
"h"
,
false
,
"print this help."
)
conf
=
flag
.
String
(
"f"
,
""
,
"specify configuration file."
)
flag
.
Parse
()
if
*
vers
{
fmt
.
Println
(
"Version:"
,
version
)
os
.
Exit
(
0
)
}
if
*
help
{
flag
.
Usage
()
os
.
Exit
(
0
)
}
runner
.
Init
()
fmt
.
Println
(
"runner.cwd:"
,
runner
.
Cwd
)
fmt
.
Println
(
"runner.hostname:"
,
runner
.
Hostname
)
}
func
main
()
{
aconf
()
parseConf
()
conf
:=
config
.
Config
...
...
@@ -146,12 +179,31 @@ func main() {
}
func
parseConf
()
{
if
err
:=
config
.
Parse
();
err
!=
nil
{
if
err
:=
config
.
Parse
(
*
conf
);
err
!=
nil
{
fmt
.
Println
(
"cannot parse configuration file:"
,
err
)
os
.
Exit
(
1
)
}
}
func
aconf
()
{
if
*
conf
!=
""
&&
file
.
IsExist
(
*
conf
)
{
return
}
*
conf
=
"etc/server.local.yml"
if
file
.
IsExist
(
*
conf
)
{
return
}
*
conf
=
"etc/server.yml"
if
file
.
IsExist
(
*
conf
)
{
return
}
fmt
.
Println
(
"no configuration file for server"
)
os
.
Exit
(
1
)
}
func
checkIdentity
()
{
ip
,
err
:=
identity
.
GetIP
()
if
err
!=
nil
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录