diff --git a/.github/workflows/dashboard.yml b/.github/workflows/dashboard.yml index 148daaa..5bbcb21 100644 --- a/.github/workflows/dashboard.yml +++ b/.github/workflows/dashboard.yml @@ -22,6 +22,8 @@ jobs: - name: Build and push dasbboard image run: | + go env go test -v ./... - docker build -t ghcr.io/${{ github.repository_owner }}/nezha-dashboard -f Dockerfile . - docker push ghcr.io/${{ github.repository_owner }}/nezha-dashboard + IMAGE_NAME=$(echo "ghcr.io/${{ github.repository_owner }}/nezha-dashboard" | tr '[:upper:]' '[:lower:]') + docker build -t $IMAGE_NAME -f Dockerfile . + docker push $IMAGE_NAME diff --git a/cmd/dashboard/controller/common_page.go b/cmd/dashboard/controller/common_page.go index 57a4bae..68a0693 100644 --- a/cmd/dashboard/controller/common_page.go +++ b/cmd/dashboard/controller/common_page.go @@ -185,6 +185,7 @@ func (cp *commonPage) ws(c *gin.Context) { return } defer conn.Close() + count := 0 for { dao.SortedServerLock.RLock() err = conn.WriteJSON(dao.SortedServerList) @@ -192,6 +193,13 @@ func (cp *commonPage) ws(c *gin.Context) { if err != nil { break } + count += 1 + if count%4 == 0 { + err = conn.WriteMessage(websocket.PingMessage, []byte{}) + if err != nil { + break + } + } time.Sleep(time.Second * 2) } }