Selaa lähdekoodia

queue call queue dir

stanley-king 4 vuotta sitten
vanhempi
commit
bb896d40a9
4 muutettua tiedostoa jossa 49 lisäystä ja 51 poistoa
  1. 41 41
      queue/control/index.php
  2. 5 4
      queue/control/queue.php
  3. 1 2
      queue/index.php
  4. 2 4
      qwatch.php

+ 41 - 41
queue/control/index.php

@@ -1,42 +1,42 @@
-<?php
-/**
- * 队列
-*
-*
-*
-*
-
-*/
-defined('InShopNC') or exit('Access Invalid!');
-
-class indexControl 
-{
-    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, time());
-                    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);
-        }
-    }
+<?php
+/**
+ * 队列
+*
+*
+*
+*
+
+*/
+defined('InShopNC') or exit('Access Invalid!');
+
+class indexControl 
+{
+    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, time());
+                    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);
+        }
+    }
 }

+ 5 - 4
queue/control/queue.php

@@ -1,4 +1,5 @@
 <?php
+declare(strict_types=0);
 /**
  * 队列
 *
@@ -11,7 +12,7 @@ defined('InShopNC') or exit('Access Invalid!');
 //此行代码会导致bug
 //ini_set('default_socket_timeout', -1);
 
-class queueControl extends BaseCronControl
+class queueControl
 {
     private $_stop = false;
 
@@ -43,12 +44,12 @@ class queueControl extends BaseCronControl
                     $method = key($content);
                     $arg = current($content);
 
-                    $argx = json_encode($arg,JSON_UNESCAPED_UNICODE);
+                    $argstr = json_encode($arg,JSON_UNESCAPED_UNICODE);
+                    Log::record("method={$method} args={$argstr}",Log::DEBUG);
 
-                    Log::record("method={$method} args={$argx}",Log::DEBUG);
                     $result = $logic_queue->$method($arg);
                     if (!$result['state']) {
-                        $this->log($result['msg'],false);
+                        Log::record("{$method} run error: {$result['msg']}",Log::ERR);
                     }
                     $empty_times = 0;
                 }

+ 1 - 2
queue/index.php

@@ -21,5 +21,4 @@ $_GET['act'] = $_SERVER['argv'][1];
 $_GET['op']  = $_SERVER['argv'][2];
 if (!@include(BASE_PATH . '/control/control.php')) exit('control.php isn\'t exists!');
 
-Base::run();
-?>
+Base::run();

+ 2 - 4
qwatch.php

@@ -1,9 +1,8 @@
 <?php
 declare(strict_types=1);
 
-define('APP_ID','queue');
 define('BASE_ROOT_PATH',str_replace('\\','/',dirname(__FILE__)));
-define('BASE_PATH', BASE_ROOT_PATH . '/crontab');
+define('BASE_PATH', BASE_ROOT_PATH . '/queue');
 
 require_once(BASE_ROOT_PATH . '/global.php');
 require_once(BASE_ROOT_PATH . '/fooder.php');
@@ -14,8 +13,7 @@ if (!@include(BASE_PATH.'/control/control.php')) exit('control.php isn\'t exists
 $_GET['act'] = 'queue';
 $_GET['op']  = 'index';
 
-function work_proc()
-{
+function work_proc() {
     Base::run();
 }