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:
JellyTony 2022-11-04 15:18:36 +08:00 committed by GitHub
parent 352415662a
commit 8a145d5ba2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 1 deletions

View File

@ -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

View File

@ -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

View File

@ -312,6 +312,7 @@ type SMTPConfig struct {
}
type Alerting struct {
Timeout int64
TemplatesDir string
NotifyConcurrency int
NotifyBuiltinChannels []string

View File

@ -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 {