修复DAU统计导致无法提示进程在运行的问题

This commit is contained in:
GoEdgeLab
2024-04-15 16:06:16 +08:00
parent a63b530c09
commit 8ac6a421c0
2 changed files with 20 additions and 10 deletions

View File

@@ -89,6 +89,14 @@ func NewBandwidthStatManager() *BandwidthStatManager {
}
func (this *BandwidthStatManager) Start() {
// 初始化DAU统计
{
err := SharedDAUManager.Init()
if err != nil {
remotelogs.Error("DAU_MANAGER", "initialize DAU manager failed: "+err.Error())
}
}
// 从上次数据中恢复
this.locker.Lock()
this.recover()

View File

@@ -4,7 +4,6 @@ package stats
import (
"encoding/json"
teaconst "github.com/TeaOSLab/EdgeNode/internal/const"
"github.com/TeaOSLab/EdgeNode/internal/events"
"github.com/TeaOSLab/EdgeNode/internal/goman"
"github.com/TeaOSLab/EdgeNode/internal/remotelogs"
@@ -25,21 +24,14 @@ import (
var SharedDAUManager = NewDAUManager()
func init() {
if teaconst.IsMain {
err := SharedDAUManager.Init()
if err != nil {
remotelogs.Error("DAU_MANAGER", "initialize DAU manager failed: "+err.Error())
}
}
}
type IPInfo struct {
IP string
ServerId int64
}
type DAUManager struct {
isReady bool
cacheFile string
ipChan chan IPInfo
@@ -148,6 +140,8 @@ func (this *DAUManager) Init() error {
_ = this.Close()
})
this.isReady = true
return nil
}
@@ -162,6 +156,10 @@ func (this *DAUManager) AddIP(serverId int64, ip string) {
}
func (this *DAUManager) processIP(serverId int64, ip string) error {
if !this.isReady {
return nil
}
// day
var date = fasttime.Now().Ymd()
@@ -228,6 +226,10 @@ func (this *DAUManager) Close() error {
}
func (this *DAUManager) CleanStats() error {
if !this.isReady {
return nil
}
var tr = trackers.Begin("STAT:DAU_CLEAN_STATS")
defer tr.End()