mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2025-05-11 10:25:52 +02:00
refactor: nodes analytics (#847)
* refactor: nodes analytics * feat(debug): add pprof in debug mode * refactor: websocket error handler
This commit is contained in:
parent
b1ba719cb1
commit
cb4977e5ab
17 changed files with 276 additions and 155 deletions
|
@ -2,6 +2,10 @@ package analytic
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"runtime"
|
||||
"time"
|
||||
|
||||
"github.com/0xJacky/Nginx-UI/internal/analytic"
|
||||
"github.com/0xJacky/Nginx-UI/internal/helper"
|
||||
"github.com/shirou/gopsutil/v4/cpu"
|
||||
|
@ -10,9 +14,6 @@ import (
|
|||
"github.com/shirou/gopsutil/v4/net"
|
||||
"github.com/spf13/cast"
|
||||
"github.com/uozi-tech/cosy/logger"
|
||||
"net/http"
|
||||
"runtime"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/gorilla/websocket"
|
||||
|
@ -86,12 +87,14 @@ func Analytic(c *gin.Context) {
|
|||
|
||||
// write
|
||||
err = ws.WriteJSON(stat)
|
||||
if helper.IsUnexpectedWebsocketError(err) {
|
||||
logger.Error(err)
|
||||
if err != nil {
|
||||
if helper.IsUnexpectedWebsocketError(err) {
|
||||
logger.Error(err)
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
time.Sleep(1000 * time.Microsecond)
|
||||
time.Sleep(1 * time.Second)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue