Merge pull request #118 from Erope/pull

WebSocket增加Ping包 & Actions构建镜像时用户名转为小写

Co-authored-by: Erope <44471469+Erope@users.noreply.github.com>
This commit is contained in:
naiba
2021-04-04 23:12:10 +08:00
committed by GitHub
2 changed files with 12 additions and 2 deletions

View File

@@ -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

View File

@@ -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)
}
}