Browse Source

Merge branch 'feature/eta2.5.9_api_stat' into debug

xyxie 1 day ago
parent
commit
a6921173c0
1 changed files with 14 additions and 13 deletions
  1. 14 13
      services/websocket_msg.go

+ 14 - 13
services/websocket_msg.go

@@ -6,6 +6,7 @@ import (
 	"eta/eta_api/services/data"
 	"eta/eta_api/utils"
 	"fmt"
+	"runtime"
 	"sync"
 	"time"
 
@@ -24,19 +25,19 @@ func DealEdbInspectionMessage(connKey string, conn *websocket.Conn, adminId int)
 	ctx, cancel := context.WithCancel(context.Background())
 	defer cancel()
 
-	// // 监控 goroutine 数量
-	// go func() {
-	// 	ticker := time.NewTicker(time.Minute)
-	// 	defer ticker.Stop()
-	// 	for {
-	// 		select {
-	// 		case <-ticker.C:
-	// 			utils.FileLog.Info("Current goroutine count: %d", runtime.NumGoroutine())
-	// 		case <-ctx.Done():
-	// 			return
-	// 		}
-	// 	}
-	// }()
+	// 监控 goroutine 数量
+	go func() {
+		ticker := time.NewTicker(time.Minute)
+		defer ticker.Stop()
+		for {
+			select {
+			case <-ticker.C:
+				utils.FileLog.Info("Current goroutine count: %d", runtime.NumGoroutine())
+			case <-ctx.Done():
+				return
+			}
+		}
+	}()
 
 	cacheKey := fmt.Sprintf("%s%d", utils.CACHE_EDB_INSPECTION_MESSAGE, adminId)