mirror of
https://github.com/astaxie/beego.git
synced 2024-11-22 09:20:55 +00:00
1.fix start task twice issue
This commit is contained in:
parent
88c5dfa6ea
commit
710c7c79d4
@ -389,11 +389,16 @@ func dayMatches(s *Schedule, t time.Time) bool {
|
||||
|
||||
// StartTask start all tasks
|
||||
func StartTask() {
|
||||
if isstart {
|
||||
//If already started, no need to start another goroutine.
|
||||
return
|
||||
}
|
||||
isstart = true
|
||||
go run()
|
||||
}
|
||||
|
||||
func run() {
|
||||
|
||||
now := time.Now().Local()
|
||||
for _, t := range AdminTaskList {
|
||||
t.SetNext(now)
|
||||
@ -432,10 +437,13 @@ func run() {
|
||||
|
||||
// StopTask stop all tasks
|
||||
func StopTask() {
|
||||
if(isstart){
|
||||
isstart = false
|
||||
stop <- true
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// AddTask add task with name
|
||||
func AddTask(taskname string, t Tasker) {
|
||||
AdminTaskList[taskname] = t
|
||||
|
Loading…
Reference in New Issue
Block a user