|
@@ -2,6 +2,7 @@ package main
|
|
|
|
|
|
|
|
import (
|
|
import (
|
|
|
"runtime/debug"
|
|
"runtime/debug"
|
|
|
|
|
+ "sync/atomic"
|
|
|
"time"
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/sirupsen/logrus"
|
|
"github.com/sirupsen/logrus"
|
|
@@ -11,8 +12,9 @@ import (
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
var (
|
|
|
- StatYestodayStartMinute = 30
|
|
|
|
|
- StatCurrentdayStartMinute = 10
|
|
|
|
|
|
|
+ StatYestodayStartMinute = 30
|
|
|
|
|
+ StatCurrentdayStartMinute = 10
|
|
|
|
|
+ isRunning int32 = 0
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
// CalcLightingRate 临时使用
|
|
// CalcLightingRate 临时使用
|
|
@@ -49,6 +51,12 @@ func GetNext15minite(t time.Time) time.Time {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func StatData(args ...interface{}) interface{} {
|
|
func StatData(args ...interface{}) interface{} {
|
|
|
|
|
+ if !atomic.CompareAndSwapInt32(&isRunning, 0, 1) {
|
|
|
|
|
+ logrus.Info("StatData 已有实例在运行,直接退出")
|
|
|
|
|
+ return nil
|
|
|
|
|
+ }
|
|
|
|
|
+ defer atomic.StoreInt32(&isRunning, 0)
|
|
|
|
|
+
|
|
|
defer func() {
|
|
defer func() {
|
|
|
if err := recover(); err != nil {
|
|
if err := recover(); err != nil {
|
|
|
logrus.Error("StatData发生异常:", err)
|
|
logrus.Error("StatData发生异常:", err)
|