mirror of
https://github.com/Sagit-chu/flvx.git
synced 2026-10-09 03:06:37 +08:00
修复流量统计
This commit is contained in:
@@ -118,7 +118,6 @@ func main() {
|
||||
log := xlogger.NewLogger()
|
||||
logger.SetDefault(log)
|
||||
|
||||
// 使用内存流量管理器
|
||||
trafficMgr := traffic.GetGlobalManager()
|
||||
defer trafficMgr.Close()
|
||||
|
||||
|
||||
@@ -36,13 +36,13 @@ func StartTrafficReporter(trafficMgr traffic.Manager) {
|
||||
return
|
||||
}
|
||||
|
||||
ticker := time.NewTicker(1 * time.Second)
|
||||
ticker := time.NewTicker(5 * time.Second)
|
||||
|
||||
go func() {
|
||||
defer ticker.Stop()
|
||||
|
||||
for range ticker.C {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
|
||||
// 先获取流量统计(不清零)
|
||||
stats, err := trafficMgr.GetAllServicesStats(ctx)
|
||||
|
||||
@@ -126,7 +126,7 @@ func (h *forwardHandler) Handle(ctx context.Context, conn net.Conn, opts ...hand
|
||||
|
||||
if h.trafficManager != nil {
|
||||
go func() {
|
||||
ticker := time.NewTicker(1 * time.Second)
|
||||
ticker := time.NewTicker(5 * time.Second)
|
||||
defer ticker.Stop()
|
||||
|
||||
// 记录上次的流量值
|
||||
|
||||
Reference in New Issue
Block a user