|
@@ -4,13 +4,12 @@ import (
|
|
"cicv-data-closedloop/kinglong/common/cfg"
|
|
"cicv-data-closedloop/kinglong/common/cfg"
|
|
"cicv-data-closedloop/kinglong/common/log"
|
|
"cicv-data-closedloop/kinglong/common/log"
|
|
"cicv-data-closedloop/kinglong/common/util"
|
|
"cicv-data-closedloop/kinglong/common/util"
|
|
- commonConfig "cicv-data-closedloop/pji/common/cfg"
|
|
|
|
"time"
|
|
"time"
|
|
)
|
|
)
|
|
|
|
|
|
// BagCacheClean 保证本地缓存的包数量不超过设定值
|
|
// BagCacheClean 保证本地缓存的包数量不超过设定值
|
|
func BagCacheClean() {
|
|
func BagCacheClean() {
|
|
- log.GlobalLogger.Info("启动清理缓存的 goroutine 维护 data 目录内的 bag 包数量:", commonConfig.CloudConfig.BagNumber)
|
|
|
|
|
|
+ log.GlobalLogger.Info("启动清理缓存的 goroutine 维护 data 目录内的 bag 包数量:", cfg.CloudConfig.BagNumber)
|
|
for {
|
|
for {
|
|
// 收到自杀信号
|
|
// 收到自杀信号
|
|
if signal := <-ChannelKillDiskClean; signal == 1 {
|
|
if signal := <-ChannelKillDiskClean; signal == 1 {
|
|
@@ -18,15 +17,12 @@ func BagCacheClean() {
|
|
}
|
|
}
|
|
|
|
|
|
// 1 ------- 每10秒清理一次 -------
|
|
// 1 ------- 每10秒清理一次 -------
|
|
- time.Sleep(time.Duration(10) * time.Second)
|
|
|
|
|
|
+ time.Sleep(time.Duration(500) * time.Millisecond)
|
|
// 2 ------- 获取目录下所有bag包 -------
|
|
// 2 ------- 获取目录下所有bag包 -------
|
|
bags := util.ListAbsolutePathWithSuffixAndSort(cfg.CloudConfig.BagDataDir, ".bag")
|
|
bags := util.ListAbsolutePathWithSuffixAndSort(cfg.CloudConfig.BagDataDir, ".bag")
|
|
// 3 如果打包数量超过n个,删除最旧的包{
|
|
// 3 如果打包数量超过n个,删除最旧的包{
|
|
if len(bags) > cfg.CloudConfig.BagNumber {
|
|
if len(bags) > cfg.CloudConfig.BagNumber {
|
|
- diff := len(bags) - cfg.CloudConfig.BagNumber
|
|
|
|
- for i := 0; i < diff; i++ {
|
|
|
|
- util.DeleteFile(bags[i])
|
|
|
|
- }
|
|
|
|
|
|
+ util.DeleteFile(bags[0])
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|