mirror of
https://github.com/Buriburizaem0n/nezha_domains.git
synced 2026-02-06 05:30:05 +00:00
💥 v2.0 必须更新面板,新增服务监控
This commit is contained in:
@@ -8,7 +8,6 @@ import (
|
||||
"gorm.io/gorm"
|
||||
|
||||
"github.com/naiba/nezha/model"
|
||||
pb "github.com/naiba/nezha/proto"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -16,30 +15,18 @@ const (
|
||||
ReportDelay = 2
|
||||
)
|
||||
|
||||
// Conf ..
|
||||
var Conf *model.Config
|
||||
|
||||
// Cache ..
|
||||
var Cache *cache.Cache
|
||||
|
||||
// DB ..
|
||||
var DB *gorm.DB
|
||||
|
||||
// ServerList ..
|
||||
var ServerList map[uint64]*model.Server
|
||||
var SortedServerList []*model.Server
|
||||
|
||||
// ServerLock ..
|
||||
var ServerLock sync.RWMutex
|
||||
|
||||
// Version ..
|
||||
var Version = "debug"
|
||||
|
||||
func init() {
|
||||
if len(Version) > 7 {
|
||||
Version = Version[:7]
|
||||
}
|
||||
}
|
||||
var Version = "v0.2.0"
|
||||
|
||||
func ReSortServer() {
|
||||
SortedServerList = []*model.Server{}
|
||||
@@ -51,19 +38,3 @@ func ReSortServer() {
|
||||
return SortedServerList[i].DisplayIndex > SortedServerList[j].DisplayIndex
|
||||
})
|
||||
}
|
||||
|
||||
// SendCommand ..
|
||||
func SendCommand(cmd *pb.Command) {
|
||||
ServerLock.RLock()
|
||||
defer ServerLock.RUnlock()
|
||||
var err error
|
||||
for _, server := range ServerList {
|
||||
if server.Stream != nil {
|
||||
err = server.Stream.Send(cmd)
|
||||
if err != nil {
|
||||
close(server.StreamClose)
|
||||
server.Stream = nil
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user