|
@@ -28,6 +28,7 @@ type CustomManager struct {
|
|
UserGroup map[string]int // 月活用户
|
|
UserGroup map[string]int // 月活用户
|
|
BatchFlag string // 批次标识
|
|
BatchFlag string // 批次标识
|
|
StopSearch chan bool // 停止查询信号
|
|
StopSearch chan bool // 停止查询信号
|
|
|
|
+ IsDoSearch bool // 是否正在查询
|
|
sync.RWMutex
|
|
sync.RWMutex
|
|
}
|
|
}
|
|
|
|
|
|
@@ -93,7 +94,9 @@ func (this *CustomManager) ScheduledTasks() {
|
|
//开始
|
|
//开始
|
|
startJob := cron.New(cron.WithSeconds())
|
|
startJob := cron.New(cron.WithSeconds())
|
|
if _, err := startJob.AddFunc(this.Conf.SearchLimit.Switch.Start, func() {
|
|
if _, err := startJob.AddFunc(this.Conf.SearchLimit.Switch.Start, func() {
|
|
- go this.DoSearch()
|
|
|
|
|
|
+ if !this.IsDoSearch {
|
|
|
|
+ go this.DoSearch()
|
|
|
|
+ }
|
|
}); err != nil {
|
|
}); err != nil {
|
|
panic(err)
|
|
panic(err)
|
|
}
|
|
}
|
|
@@ -101,7 +104,9 @@ func (this *CustomManager) ScheduledTasks() {
|
|
//结束
|
|
//结束
|
|
endJob := cron.New(cron.WithSeconds())
|
|
endJob := cron.New(cron.WithSeconds())
|
|
if _, err := endJob.AddFunc(this.Conf.SearchLimit.Switch.Stop, func() {
|
|
if _, err := endJob.AddFunc(this.Conf.SearchLimit.Switch.Stop, func() {
|
|
- this.StopSearch <- true
|
|
|
|
|
|
+ if this.IsDoSearch {
|
|
|
|
+ this.StopSearch <- true
|
|
|
|
+ }
|
|
}); err != nil {
|
|
}); err != nil {
|
|
panic(err)
|
|
panic(err)
|
|
}
|
|
}
|
|
@@ -248,6 +253,10 @@ func (this *CustomManager) newUserQueue(batchFlag string) {
|
|
|
|
|
|
// DoSearch 定制化分析报告查询队列
|
|
// DoSearch 定制化分析报告查询队列
|
|
func (this *CustomManager) DoSearch() {
|
|
func (this *CustomManager) DoSearch() {
|
|
|
|
+ this.IsDoSearch = true
|
|
|
|
+ defer func() {
|
|
|
|
+ this.IsDoSearch = false
|
|
|
|
+ }()
|
|
log.Printf("[MANAGER-INFO]CustomManager DoSearch Start\n")
|
|
log.Printf("[MANAGER-INFO]CustomManager DoSearch Start\n")
|
|
for {
|
|
for {
|
|
var obj *SearchEntity
|
|
var obj *SearchEntity
|