diff --git a/go.mod b/go.mod index 940cfd7..6d393b2 100644 --- a/go.mod +++ b/go.mod @@ -18,6 +18,7 @@ require ( github.com/ory/graceful v0.1.1 github.com/p14yground/go-github-selfupdate v0.0.0-20210520015421-eddf14461293 github.com/patrickmn/go-cache v2.1.0+incompatible + github.com/pkg/errors v0.9.1 // indirect github.com/robfig/cron/v3 v3.0.1 github.com/shirou/gopsutil/v3 v3.21.7 github.com/spf13/viper v1.7.1 diff --git a/go.sum b/go.sum index 8d4cf3b..6ee4cba 100644 --- a/go.sum +++ b/go.sum @@ -262,9 +262,10 @@ github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTK github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= diff --git a/service/dao/servicesentinel.go b/service/dao/servicesentinel.go index 53c8d35..c82920f 100644 --- a/service/dao/servicesentinel.go +++ b/service/dao/servicesentinel.go @@ -100,11 +100,13 @@ type ServiceSentinel struct { } func (ss *ServiceSentinel) refreshMonthlyServiceStatus() { + // 刷新数据防止无人访问 + ss.LoadStats() + // 将数据往前刷一天 ss.monthlyStatusLock.Lock() defer ss.monthlyStatusLock.Unlock() - // 将数据往前搦 for _, v := range ss.monthlyStatus { - for i := 0; i < len(v.Up)-2; i++ { + for i := 0; i < len(v.Up)-1; i++ { v.Up[i] = v.Up[i+1] v.Down[i] = v.Down[i+1] v.Delay[i] = v.Delay[i+1]