💥 v2.0 必须更新面板,新增服务监控

This commit is contained in:
naiba
2021-01-16 00:45:49 +08:00
parent 0ce8017875
commit a41c792577
38 changed files with 1015 additions and 453 deletions

View File

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