add EngineDelay

This commit is contained in:
UlricQin 2021-12-01 14:09:08 +08:00
parent 57c2fd9b73
commit 11e7c41908
3 changed files with 9 additions and 1 deletions

View File

@ -4,6 +4,9 @@ RunMode = "release"
# my cluster name # my cluster name
ClusterName = "Default" ClusterName = "Default"
# sleep x seconds, then start judge engine
EngineDelay = 120
[Log] [Log]
# log write dir # log write dir
Dir = "logs" Dir = "logs"

View File

@ -62,6 +62,10 @@ func MustLoad(fpaths ...string) {
} }
m.MustLoad(C) m.MustLoad(C)
if C.EngineDelay == 0 {
C.EngineDelay = 120
}
if C.Heartbeat.IP == "" { if C.Heartbeat.IP == "" {
// auto detect // auto detect
C.Heartbeat.IP = fmt.Sprint(GetOutboundIP()) C.Heartbeat.IP = fmt.Sprint(GetOutboundIP())
@ -85,6 +89,7 @@ func MustLoad(fpaths ...string) {
type Config struct { type Config struct {
RunMode string RunMode string
ClusterName string ClusterName string
EngineDelay int64
Log logx.Config Log logx.Config
HTTP httpx.Config HTTP httpx.Config
BasicAuth gin.Accounts BasicAuth gin.Accounts

View File

@ -20,7 +20,7 @@ import (
func loopFilterRules(ctx context.Context) { func loopFilterRules(ctx context.Context) {
// wait for samples // wait for samples
time.Sleep(time.Minute * 2) time.Sleep(time.Duration(config.C.EngineDelay) * time.Second)
duration := time.Duration(9000) * time.Millisecond duration := time.Duration(9000) * time.Millisecond
for { for {