️ WS 通信阻塞读写锁

This commit is contained in:
naiba 2022-03-13 10:44:30 +08:00
parent d60bc3dad6
commit d928f65052
3 changed files with 6 additions and 4 deletions

View File

@ -4,7 +4,7 @@
<br> <br>
<small><i>LOGO designed by <a href="https://xio.ng" target="_blank">熊大</a> .</i></small> <small><i>LOGO designed by <a href="https://xio.ng" target="_blank">熊大</a> .</i></small>
<br><br> <br><br>
<img src="https://img.shields.io/github/workflow/status/naiba/nezha/Dashboard%20image?label=Dash%20v0.12.11&logo=github&style=for-the-badge">&nbsp;<img src="https://img.shields.io/github/v/release/naiba/nezha?color=brightgreen&label=Agent&style=for-the-badge&logo=github">&nbsp;<img src="https://img.shields.io/github/workflow/status/naiba/nezha/Agent%20release?label=Agent%20CI&logo=github&style=for-the-badge">&nbsp;<img src="https://img.shields.io/badge/Installer-v0.8.1-brightgreen?style=for-the-badge&logo=linux"> <img src="https://img.shields.io/github/workflow/status/naiba/nezha/Dashboard%20image?label=Dash%20v0.12.12&logo=github&style=for-the-badge">&nbsp;<img src="https://img.shields.io/github/v/release/naiba/nezha?color=brightgreen&label=Agent&style=for-the-badge&logo=github">&nbsp;<img src="https://img.shields.io/github/workflow/status/naiba/nezha/Agent%20release?label=Agent%20CI&logo=github&style=for-the-badge">&nbsp;<img src="https://img.shields.io/badge/Installer-v0.8.1-brightgreen?style=for-the-badge&logo=linux">
<br> <br>
<br> <br>
<p>:trollface: <b>哪吒监控</b> 一站式轻监控轻运维系统。支持系统状态、HTTP(SSL 证书变更、即将到期、到期)、TCP、Ping 监控报警,计划任务和在线终端。</p> <p>:trollface: <b>哪吒监控</b> 一站式轻监控轻运维系统。支持系统状态、HTTP(SSL 证书变更、即将到期、到期)、TCP、Ping 监控报警,计划任务和在线终端。</p>

View File

@ -140,14 +140,16 @@ func (cp *commonPage) ws(c *gin.Context) {
return return
} }
defer conn.Close() defer conn.Close()
var servers []*model.Server
count := 0 count := 0
for { for {
singleton.SortedServerLock.RLock() singleton.SortedServerLock.RLock()
servers = singleton.SortedServerList
singleton.SortedServerLock.RUnlock()
err = conn.WriteJSON(Data{ err = conn.WriteJSON(Data{
Now: time.Now().Unix() * 1000, Now: time.Now().Unix() * 1000,
Servers: singleton.SortedServerList, Servers: servers,
}) })
singleton.SortedServerLock.RUnlock()
if err != nil { if err != nil {
break break
} }

View File

@ -14,7 +14,7 @@ import (
pb "github.com/naiba/nezha/proto" pb "github.com/naiba/nezha/proto"
) )
var Version = "v0.12.11" // !!记得修改 README 中的 badge 版本!! var Version = "v0.12.12" // !!记得修改 README 中的 badge 版本!!
var ( var (
Conf *model.Config Conf *model.Config