vali 6 年之前
父节点
当前提交
cfad10c63e

+ 8 - 0
vendor/GatewayWorker_windows/Applications/whisper/Events.php

@@ -1791,6 +1791,13 @@ class Events
             unset($oldKey, $key);
         }
 
+        // 每1分钟做一次redis ping检测避免redis掉线
+        Timer::add(60, function () {
+            if (!self::$logic->RedisPing()) {
+                self::$logic->getRedis(0);
+            }
+        });
+
         if (strtolower(substr(PHP_OS, 0, 3)) == 'win') {
             // 定时统计数据
             if (0 == $worker->id) {
@@ -1891,6 +1898,7 @@ class Events
                     unset(self::$global->$oldKey);
                 });
 
+
             } else {
                 // 管理员实时监控.
                 Timer::add(20, function () {

+ 4 - 1
vendor/GatewayWorker_windows/Applications/whisper/Mlogic.php

@@ -68,6 +68,7 @@ class Mlogic
         $conf = require(self::$configPath . 'database.php');
         self::$db = new \Workerman\MySQL\Connection($conf['hostname'], $conf['hostport'], $conf['username'], $conf['password'], $conf['database']);
 
+
         return self::$db;
     }
 
@@ -93,6 +94,7 @@ class Mlogic
         }
         $redis->select($conf['db']);
         self::$redisTime = time();
+        echo "Redis Reconnect : " . date("Y-m-d H:i:s") . "\n";
 
         self::$redis = $redis;
         return self::$redis;
@@ -102,7 +104,8 @@ class Mlogic
     public static function RedisPing()
     {
         $ret = self::$redis->ping();
-        if (strpos("PONG", strtolower($ret)) !== false) {
+        echo "redisPing: " . date("Y-m-d H:i:s") . ' - ' . $ret . "\n";
+        if (strpos(strtoupper($ret), "PONG") !== false) {
             return true;
         }
         return false;