Esempio n. 1
0
func main() {
	runtime.GOMAXPROCS(8)
	go start()
	go heartbeat()
	for {
		task := Load("http://task.open-ns.org/task.json")
		if IS_WORKER {
			util.DEBUG("load user [%d] size", task.Size)
			util.INFO("worker is true, go jobs")
			Jobs(task)
		}
		util.DEBUG("task size: %d, queue size: %d", len(CURRENT_TASK), QUEUE.Len())
		time.Sleep(time.Duration(3) * time.Second)
	}
}
Esempio n. 2
0
func Task(user *entity.User) {
	runtime.Gosched()
	util.DEBUG("add job username: %s", user.UserName)
	for {
		if _, ok := CURRENT_TASK[fmt.Sprintf(FMT, user.UserName, user.Trigger)]; ok {
			util.DEBUG("loop task username: %s, trigger: %d, current: %d", user.UserName, user.Trigger, time.Now().Unix())
			if time.Now().After(user.Date) && time.Now().Unix()-user.Trigger < RANGE_TIME {
				util.DEBUG("jobs username: %s, password: %s, start: %t, trigger: %d, date: %s",
					user.UserName, user.PassWord, user.Start, user.Trigger, user.Date)
				QUEUE.PushBack(user)
				break
			} else {
				time.Sleep(time.Duration(10) * time.Second)
			}
		} else {
			break
		}
	}
}