mirror of
https://github.com/Buriburizaem0n/nezha_domains.git
synced 2026-02-04 04:30:05 +00:00
Merge pull request #142 from lemoeo/main
✨ 反向代理 gRPC 端口(支持 Cloudflare CDN) Co-authored-by: lemoeo <18618627+lemoeo@users.noreply.github.com>
This commit is contained in:
@@ -218,6 +218,8 @@ func doTask(task *pb.Task) {
|
||||
handleCommandTask(task, &result)
|
||||
case model.TaskTypeUpgrade:
|
||||
handleUpgradeTask(task, &result)
|
||||
case model.TaskTypeKeepalive:
|
||||
return
|
||||
default:
|
||||
println("不支持的任务:", task)
|
||||
}
|
||||
|
||||
@@ -193,6 +193,7 @@ func main() {
|
||||
go rpc.ServeRPC(dao.Conf.GRPCPort)
|
||||
serviceSentinelDispatchBus := make(chan model.Monitor)
|
||||
go rpc.DispatchTask(serviceSentinelDispatchBus)
|
||||
go rpc.DispatchKeepalive()
|
||||
go dao.AlertSentinelStart()
|
||||
dao.NewServiceSentinel(serviceSentinelDispatchBus)
|
||||
srv := controller.ServeWeb(dao.Conf.HTTPPort)
|
||||
|
||||
@@ -57,3 +57,17 @@ func DispatchTask(serviceSentinelDispatchBus <-chan model.Monitor) {
|
||||
dao.SortedServerLock.RUnlock()
|
||||
}
|
||||
}
|
||||
|
||||
func DispatchKeepalive() {
|
||||
dao.Cron.AddFunc("@every 60s", func() {
|
||||
dao.SortedServerLock.RLock()
|
||||
defer dao.SortedServerLock.RUnlock()
|
||||
for i := 0; i < len(dao.SortedServerList); i++ {
|
||||
if dao.SortedServerList[i] == nil || dao.SortedServerList[i].TaskStream == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
dao.SortedServerList[i].TaskStream.Send(&pb.Task{Type: model.TaskTypeKeepalive})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user