예제 #1
0
파일: cron.php 프로젝트: vazahat/dudex
 public function processScheduler()
 {
     /**
      * following step to speed up & beat performance
      * 1. check album limit
      * 2. check quota limit
      * 3. get nodes of this schedulers
      * 4. get all items of current schedulers.
      * 5. process each node
      * 5.1 check required quota
      * 5.2 fetch data to pubic file
      * 5.3 store to file model
      * 6. check status of schedulers, if scheduler is completed == (remaining == 0)
      * 6.1 udpate feed and message.
      */
     /**
      * Unlimited time.
      */
     set_time_limit(0);
     /**
      * default 20
      * @var int
      */
     $configs = OW::getConfig()->getValues('ynmediaimporter');
     $limitUserPerCron = $configs['number_photo'] ? intval($configs['number_photo']) : 20;
     /**
      * default 20
      * @var int
      */
     $limitQueuePerCron = $configs['number_queue'] ? intval($configs['number_queue']) : 20;
     /**
      * process number queue.
      */
     /**
      * get scheduler from tables data.
      */
     $example = new OW_Example();
     $example->andFieldLessThan('status', '3');
     $example->setOrder('last_run');
     $example->setLimitClause($first, $count)->setLimitClause(0, $limitQueuePerCron);
     $schedulers = YNMEDIAIMPORTER_BOL_SchedulerDao::getInstance()->findListByExample($example);
     foreach ($schedulers as $scheduler) {
         Ynmediaimporter::processScheduler($scheduler, 0, $limitUserPerCron, 1, 1);
     }
     echo "success!";
     exit(0);
 }
예제 #2
0
파일: importer.php 프로젝트: vazahat/dudex
 public function scheduler($params)
 {
     register_shutdown_function(array($this, 'handleShutdown'));
     ini_set('max_execution_time', 12);
     /**
      * following step to speed up & beat performance
      * 1. check album limit
      * 2. check quota limit
      * 3. get nodes of this schedulers
      * 4. get all items of current schedulers.
      * 5. process each node
      * 5.1 check required quota
      * 5.2 fetch data to pubic file
      * 5.3 store to file model
      * 6. check status of schedulers, if scheduler is completed == (remaining == 0)
      * 6.1 udpate feed and message.
      */
     /**
      * Unlimited time.
      */
     //set_time_limit(0);
     $schedulerId = $params['scheduler_id'];
     $scheduler = YNMEDIAIMPORTER_BOL_SchedulerDao::getInstance()->findById($schedulerId);
     /**
      * check Ynmediaimporter::processScheduler for futher information.
      *
      */
     $result = Ynmediaimporter::processScheduler($scheduler, 0, 10, 1, 1);
     /**
      * get remain
      * @see Ynmediaimporter::processScheduler
      */
     $remain = $result['remain'];
     if ($remain == 0) {
         $result['message'] = 'Your import request has been completed.';
     } else {
         $result['message'] = 'Your import request has been added to the queue.';
     }
     echo json_encode($result);
     exit(0);
 }