feat: 报警脚本超时时间改为可配置 (#1253)
* Update docker-compose.yaml * Update docker-compose.yaml * feat: 报警脚本超时时间改为可配置 * feat: docker 镜像Alerting 增加 超时时间 Co-authored-by: ulricqin <ulricqin@qq.com> Co-authored-by: JeffreyBool <zhanggaoyuan@mediatrack.cn>
This commit is contained in:
parent
352415662a
commit
8a145d5ba2
|
@ -75,6 +75,8 @@ InsecureSkipVerify = true
|
|||
Batch = 5
|
||||
|
||||
[Alerting]
|
||||
# timeout settings, unit: ms, default: 30000ms
|
||||
Timeout=30000
|
||||
TemplatesDir = "./etc/template"
|
||||
NotifyConcurrency = 10
|
||||
# use builtin go code notify
|
||||
|
|
|
@ -75,6 +75,8 @@ InsecureSkipVerify = true
|
|||
Batch = 5
|
||||
|
||||
[Alerting]
|
||||
# timeout settings, unit: ms, default: 30000ms
|
||||
Timeout=30000
|
||||
TemplatesDir = "./etc/template"
|
||||
NotifyConcurrency = 10
|
||||
# use builtin go code notify
|
||||
|
|
|
@ -312,6 +312,7 @@ type SMTPConfig struct {
|
|||
}
|
||||
|
||||
type Alerting struct {
|
||||
Timeout int64
|
||||
TemplatesDir string
|
||||
NotifyConcurrency int
|
||||
NotifyBuiltinChannels []string
|
||||
|
|
|
@ -398,6 +398,10 @@ func alertingCallScript(stdinBytes []byte) {
|
|||
return
|
||||
}
|
||||
|
||||
if config.C.Alerting.Timeout == 0 {
|
||||
config.C.Alerting.Timeout = 30000
|
||||
}
|
||||
|
||||
fpath := config.C.Alerting.CallScript.ScriptPath
|
||||
cmd := exec.Command(fpath)
|
||||
cmd.Stdin = bytes.NewReader(stdinBytes)
|
||||
|
@ -413,7 +417,7 @@ func alertingCallScript(stdinBytes []byte) {
|
|||
return
|
||||
}
|
||||
|
||||
err, isTimeout := sys.WrapTimeout(cmd, time.Duration(30)*time.Second)
|
||||
err, isTimeout := sys.WrapTimeout(cmd, time.Duration(config.C.Alerting.Timeout)*time.Millisecond)
|
||||
|
||||
if isTimeout {
|
||||
if err == nil {
|
||||
|
|
Loading…
Reference in New Issue