本文整理汇总了PHP中CronTask::markJobDone方法的典型用法代码示例。如果您正苦于以下问题:PHP CronTask::markJobDone方法的具体用法?PHP CronTask::markJobDone怎么用?PHP CronTask::markJobDone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CronTask
的用法示例。
在下文中一共展示了CronTask::markJobDone方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: runOld
/**
* Run a QueueWorker loop.
* Runs a Queue Worker process which will try to find unassigned jobs in the queue
* which it may run and try to fetch and execute them.
*
* @return void
*/
public function runOld()
{
// Enable Garbage Collector (PHP >= 5.3)
if (function_exists('gc_enable')) {
gc_enable();
}
$exit = false;
$starttime = time();
$group = null;
if (isset($this->params['group']) && !empty($this->params['group'])) {
$group = $this->params['group'];
}
while (!$exit) {
$this->out('Looking for Job....');
$data = $this->CronTask->requestJob($this->_getTaskConf(), $group);
if ($this->CronTask->exit === true) {
$exit = true;
} else {
if ($data) {
$this->out('Running Job of type "' . $data['jobtype'] . '"');
$taskname = 'queue_' . strtolower($data['jobtype']);
$return = $this->{$taskname}->run(unserialize($data['data']));
if ($return == true) {
$this->CronTask->markJobDone($data['id']);
$this->out('Job Finished.');
} else {
$failureMessage = null;
if (isset($this->{$taskname}->failureMessage) && !empty($this->{$taskname}->failureMessage)) {
$failureMessage = $this->{$taskname}->failureMessage;
}
$this->CronTask->markJobFailed($data['id'], $failureMessage);
$this->out('Job did not finish, requeued.');
}
} elseif (Configure::read('Queue.exitwhennothingtodo')) {
$this->out('nothing to do, exiting.');
$exit = true;
} else {
$exit = true;
}
// check if we are over the maximum runtime and end processing if so.
if (Configure::read('Queue.maxruntime') != 0 && time() - $starttime >= Configure::read('Queue.maxruntime')) {
$exit = true;
$this->out('Reached runtime of ' . (time() - $starttime) . ' Seconds (Max ' . Configure::read('Queue.maxruntime') . '), terminating.');
}
if ($exit || rand(0, 100) > 100 - Configure::read('Queue.gcprob')) {
$this->out('Performing Old job cleanup.');
$this->CronTask->cleanOldJobs();
}
$this->hr();
}
}
}