فهرست منبع

在退出的时候,将最后一个消息包,放回队列以加速退出。

stanley-king 3 سال پیش
والد
کامیت
0e4c657fa1
3فایلهای تغییر یافته به همراه31 افزوده شده و 14 حذف شده
  1. 2 2
      data/config/dev/base.ini.php
  2. 29 11
      helper/queue/iqueue.php
  3. 0 1
      plot/DataCenter.py

+ 2 - 2
data/config/dev/base.ini.php

@@ -46,8 +46,8 @@ $config['gip'] 		= 0;
 $config['dbdriver'] = 'mysqli';
 $config['tablepre']	= 'lrlz_';
 
-//define('SSH_TUNEL_PROD','local');
-define('SSH_TUNEL_PROD','xyz');
+define('SSH_TUNEL_PROD','local');
+//define('SSH_TUNEL_PROD','xyz');
 //define('SSH_TUNEL_PROD','lingzh');
 
 if(SSH_TUNEL_PROD ==='local') {

+ 29 - 11
helper/queue/iqueue.php

@@ -237,11 +237,20 @@ abstract class ILooper
                         $content = $this->mServer->pop($queues,1);
                         if(empty($content)) continue;
 
-                        go(function ()use ($content) {
-                            Log::record("BegigGoFunction",Log::DEBUG);
-                            $this->handle($content);
-                            Log::record("EndGoFunction",Log::DEBUG);
-                        });
+                        if($this->_stop)
+                        {
+                            foreach ($content as $key => $params) {
+                                DispatcherClient::instance()->push($key, $params);
+                            }
+                        }
+                        else
+                        {
+                            go(function ()use ($content) {
+                                Log::record("BegigGoFunction",Log::DEBUG);
+                                $this->handle($content);
+                                Log::record("EndGoFunction",Log::DEBUG);
+                            });
+                        }
                     }
                     else {
                         \Swoole\Coroutine::sleep(0.1);
@@ -257,13 +266,22 @@ abstract class ILooper
                     $content = $this->mServer->pop($queues,1);
                     if(empty($content)) continue;
 
-                    perfor_clear();
-                    perfor_start();
-                    $this->handle($content);
-                    perfor_end('Handle Request');
-                    $info = perfor_log();
+                    if($this->_stop)
+                    {
+                        foreach ($content as $key => $params) {
+                            DispatcherClient::instance()->push($key, $params);
+                        }
+                    }
+                    else
+                    {
+                        perfor_clear();
+                        perfor_start();
+                        $this->handle($content);
+                        perfor_end('Handle Request');
+                        $info = perfor_log();
+                        Log::record("{$info} \r\n",Log::DEBUG);
+                    }
                 }
-                Log::record("{$info} \r\n",Log::DEBUG);
             }
             catch (Exception $e)
             {

+ 0 - 1
plot/DataCenter.py

@@ -34,7 +34,6 @@ class DataCenter(object):
     def prepare_data(self):
         while True:
             try:
-                # pool = redis.ConnectionPool(host='121.89.223.81', port=57649, db=0)
                 pool = redis.ConnectionPool(host=self._mRHost, port=self._mRPort, db=0)
                 r = redis.Redis(connection_pool=pool)