Пример #1
0
 public function indexOp()
 {
     if (ob_get_level()) {
         ob_end_clean();
     }
     $logic_queue = Logic('queue');
     $worker = new QueueServer();
     $queues = $worker->scan();
     while (true) {
         $content = $worker->pop($queues, 1800);
         if (is_array($content)) {
             $method = key($content);
             $arg = current($content);
             $result = $logic_queue->{$method}($arg);
             if (!$result['state']) {
                 $this->log($result['msg'], false);
             }
             //                 echo date('Y-m-d H:i:s',time()).' '.$method."\n";
             //                 flush();
             //                 ob_flush();
         } else {
             $model = Model();
             $model->checkActive();
             unset($model);
             //                 echo date('Y-m-d H:i:s',time())."  ---\n";
             //                 flush();
             //                 ob_flush();
         }
     }
 }
Пример #2
0
 public function queueOp()
 {
     if (ob_get_level()) {
         ob_end_clean();
     }
     $model_queue = Model('queue', BASE_PATH);
     $worker = new QueueServer();
     while (true) {
         $list_key = $worker->scan();
         if (!empty($list_key) && is_array($list_key)) {
             foreach ($list_key as $key) {
                 $content = $worker->pop($key);
                 if (empty($content)) {
                     continue;
                 }
                 $method = key($content);
                 $arg = current($content);
                 $model_queue->{$method}($arg);
                 echo date('Y-m-d H:i:s', time()) . ' ' . $method . "\n";
                 //                     $content['time'] = date('Y-m-d H:i:s',time());
                 //                     print_R($content);
                 //                     echo "\n";
                 flush();
                 ob_flush();
             }
         }
         sleep(1);
     }
 }