From ab9dfbc578653c5c791ae803c1dbfa075a00ea98 Mon Sep 17 00:00:00 2001 From: Erope Date: Sun, 4 Apr 2021 00:22:50 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E5=A2=9E=E5=8A=A0WebSocket=E7=9A=84ping?= =?UTF-8?q?=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/dashboard/controller/common_page.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cmd/dashboard/controller/common_page.go b/cmd/dashboard/controller/common_page.go index 57a4bae..5a97624 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,10 @@ func (cp *commonPage) ws(c *gin.Context) { if err != nil { break } + count += 1 + if count%4 == 0 { + conn.WriteMessage(websocket.PingMessage, []byte{}) + } time.Sleep(time.Second * 2) } } From 44299459ffbbbe484740c14a8dbe39c59667f663 Mon Sep 17 00:00:00 2001 From: Erope Date: Sun, 4 Apr 2021 01:01:04 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E6=B2=A1=E5=95=A5=E7=94=A8=E7=9A=84?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/dashboard/controller/common_page.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cmd/dashboard/controller/common_page.go b/cmd/dashboard/controller/common_page.go index 5a97624..68a0693 100644 --- a/cmd/dashboard/controller/common_page.go +++ b/cmd/dashboard/controller/common_page.go @@ -195,7 +195,10 @@ func (cp *commonPage) ws(c *gin.Context) { } count += 1 if count%4 == 0 { - conn.WriteMessage(websocket.PingMessage, []byte{}) + err = conn.WriteMessage(websocket.PingMessage, []byte{}) + if err != nil { + break + } } time.Sleep(time.Second * 2) } From 569b3bab99a68eda6fd1222936d919345d7c0317 Mon Sep 17 00:00:00 2001 From: Erope Date: Sun, 4 Apr 2021 01:20:55 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=88=9B=E5=BB=BAdocker?= =?UTF-8?q?=E9=95=9C=E5=83=8F=E6=97=B6=E7=94=A8=E6=88=B7=E5=90=8D=E5=AD=98?= =?UTF-8?q?=E5=9C=A8=E5=A4=A7=E5=86=99=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/dashboard.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/dashboard.yml b/.github/workflows/dashboard.yml index 148daaa..01530cb 100644 --- a/.github/workflows/dashboard.yml +++ b/.github/workflows/dashboard.yml @@ -23,5 +23,6 @@ jobs: - name: Build and push dasbboard image run: | 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 From 1d6fa0dca933b220e3705520b449c1ddfb1763ab Mon Sep 17 00:00:00 2001 From: Erope Date: Sun, 4 Apr 2021 01:28:59 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E8=BE=93=E5=87=BAgo=20env?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/dashboard.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/dashboard.yml b/.github/workflows/dashboard.yml index 01530cb..5bbcb21 100644 --- a/.github/workflows/dashboard.yml +++ b/.github/workflows/dashboard.yml @@ -22,6 +22,7 @@ jobs: - name: Build and push dasbboard image run: | + go env go test -v ./... IMAGE_NAME=$(echo "ghcr.io/${{ github.repository_owner }}/nezha-dashboard" | tr '[:upper:]' '[:lower:]') docker build -t $IMAGE_NAME -f Dockerfile .