优化缓存相关代码

This commit is contained in:
GoEdgeLab
2022-04-14 10:25:34 +08:00
parent 0649eb0efe
commit 2b76fd4463
3 changed files with 35 additions and 2 deletions

View File

@@ -111,6 +111,9 @@ func (this *Node) Start() {
return
}
// 检查硬盘类型
this.checkDisk()
// 读取API配置
err = this.syncConfig(0)
if err != nil {
@@ -911,3 +914,21 @@ func (this *Node) onReload(config *nodeconfigs.NodeConfig) {
teaconst.GlobalProductName = config.ProductConfig.Name
}
}
func (this *Node) checkDisk() {
if runtime.GOOS == "linux" {
for _, path := range []string{
"/sys/block/vda/queue/rotational",
"/sys/block/sda/queue/rotational",
} {
data, err := ioutil.ReadFile(path)
if err != nil {
continue
}
if string(data) == "0" {
teaconst.DiskIsFast = true
}
break
}
}
}