mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-11-15 00:30:24 +08:00
进程退出时停止上传带宽数据
This commit is contained in:
@@ -36,6 +36,8 @@ func init() {
|
||||
})
|
||||
|
||||
events.On(events.EventQuit, func() {
|
||||
SharedBandwidthStatManager.Cancel()
|
||||
|
||||
err := SharedBandwidthStatManager.Save()
|
||||
if err != nil {
|
||||
remotelogs.Error("STAT", "save bandwidth stats failed: "+err.Error())
|
||||
@@ -277,6 +279,11 @@ func (this *BandwidthStatManager) Save() error {
|
||||
return os.WriteFile(this.cacheFile, data, 0666)
|
||||
}
|
||||
|
||||
// Cancel 取消上传
|
||||
func (this *BandwidthStatManager) Cancel() {
|
||||
this.ticker.Stop()
|
||||
}
|
||||
|
||||
// 从本地缓存文件中恢复数据
|
||||
func (this *BandwidthStatManager) recover() {
|
||||
cacheData, err := os.ReadFile(this.cacheFile)
|
||||
|
||||
Reference in New Issue
Block a user