mirror of
https://github.com/astaxie/beego.git
synced 2024-11-26 14:01:28 +00:00
Merge pull request #1909 from albertma/master
Start timer task Multiple times
This commit is contained in:
commit
4d8e1f93ff
@ -389,6 +389,10 @@ func dayMatches(s *Schedule, t time.Time) bool {
|
|||||||
|
|
||||||
// StartTask start all tasks
|
// StartTask start all tasks
|
||||||
func StartTask() {
|
func StartTask() {
|
||||||
|
if isstart {
|
||||||
|
//If already started, no need to start another goroutine.
|
||||||
|
return
|
||||||
|
}
|
||||||
isstart = true
|
isstart = true
|
||||||
go run()
|
go run()
|
||||||
}
|
}
|
||||||
@ -432,10 +436,13 @@ func run() {
|
|||||||
|
|
||||||
// StopTask stop all tasks
|
// StopTask stop all tasks
|
||||||
func StopTask() {
|
func StopTask() {
|
||||||
|
if isstart {
|
||||||
isstart = false
|
isstart = false
|
||||||
stop <- true
|
stop <- true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// AddTask add task with name
|
// AddTask add task with name
|
||||||
func AddTask(taskname string, t Tasker) {
|
func AddTask(taskname string, t Tasker) {
|
||||||
AdminTaskList[taskname] = t
|
AdminTaskList[taskname] = t
|
||||||
|
Loading…
Reference in New Issue
Block a user