当前位置: 首页>>代码示例>>PHP>>正文


PHP CronTask::markJobDone方法代码示例

本文整理汇总了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();
         }
     }
 }
开发者ID:nilBora,项目名称:konstruktor,代码行数:59,代码来源:CronShell.php


注:本文中的CronTask::markJobDone方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。