public function reQueue($task, $worker, $shell, $action, $userId, $taskId) { $time = time(); // Keep adding the timer's time interval until we get a date that is in the future! We don't want to keep queuing tasks in the past since they will execute until it catches up. while ($task['Task']['next_execution_time'] < $time) { $task['Task']['next_execution_time'] = strtotime('+' . $task['Task']['timer'] . ' hours', $task['Task']['next_execution_time']); } $task['Task']['scheduled_time'] = $this->breakTime($task['Task']['scheduled_time'], $task['Task']['timer']); $task['Task']['scheduled_time'] = date('H:i', $task['Task']['next_execution_time']); // Now that we have figured out when the next execution should happen, it's time to enqueue it. $process_id = CakeResque::enqueueAt($task['Task']['next_execution_time'], $worker, $shell, array($action, $task['Task']['next_execution_time'], $userId, $taskId), true); $task['Task']['job_id'] = $process_id; $this->id = $task['Task']['id']; $this->save($task); }
private function _pullScheduler($timestamp, $id) { $process_id = CakeResque::enqueueAt($timestamp, 'default', 'ServerShell', array('enqueuePull', $timestamp, $this->Auth->user('id'), $id), true); $this->Task->id = $id; $this->Task->saveField('job_id', $process_id); }
public function testEnqueueAtReturnFalseWhenDisabled() { $id = md5(time()); $ResqueScheduler = $this->ResqueScheduler; $ResqueScheduler::staticExpects($this->any())->method('enqueueAt')->will($this->returnValue($id)); $this->fixture['at'] = time(); extract($this->fixture); Configure::write('CakeResque.Scheduler.enabled', false); $this->assertFalse(CakeResque::enqueueAt($at, $queue, $class, $args)); $this->assertEmpty(CakeResque::$logs); }