mirror of
https://github.com/Monibuca/engine.git
synced 2025-10-07 17:40:57 +08:00
fix: avoid report block evenbus
This commit is contained in:
22
main.go
22
main.go
@@ -146,7 +146,7 @@ func Run(ctx context.Context, conf any) (err error) {
|
||||
plugin.assign()
|
||||
}
|
||||
UUID := uuid.NewString()
|
||||
reportTimer := time.NewTicker(time.Minute)
|
||||
|
||||
contentBuf := bytes.NewBuffer(nil)
|
||||
req, _ := http.NewRequestWithContext(ctx, http.MethodPost, "https://console.monibuca.com/report", nil)
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
@@ -212,8 +212,19 @@ func Run(ctx context.Context, conf any) (err error) {
|
||||
if EngineConfig.Secret != "" {
|
||||
EngineConfig.OnEvent(ctx)
|
||||
}
|
||||
var c http.Client
|
||||
c.Do(req)
|
||||
go func() {
|
||||
var c http.Client
|
||||
reportTimer := time.NewTimer(time.Minute)
|
||||
c.Do(req)
|
||||
for {
|
||||
<-reportTimer.C
|
||||
contentBuf.Reset()
|
||||
contentBuf.WriteString(fmt.Sprintf(`{"uuid":"`+UUID+`","streams":%d}`, Streams.Len()))
|
||||
req.Body = io.NopCloser(contentBuf)
|
||||
c.Do(req)
|
||||
reportTimer.Reset(time.Minute)
|
||||
}
|
||||
}()
|
||||
for _, plugin := range enabledPlugins {
|
||||
plugin.Config.OnEvent(EngineConfig) //引擎初始化完成后,通知插件
|
||||
}
|
||||
@@ -234,11 +245,6 @@ func Run(ctx context.Context, conf any) (err error) {
|
||||
}
|
||||
case <-ctx.Done():
|
||||
return
|
||||
case <-reportTimer.C:
|
||||
contentBuf.Reset()
|
||||
contentBuf.WriteString(fmt.Sprintf(`{"uuid":"`+UUID+`","streams":%d}`, Streams.Len()))
|
||||
req.Body = io.NopCloser(contentBuf)
|
||||
c.Do(req)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user