Przeglądaj źródła

redis 增加密码

vali 6 lat temu
rodzic
commit
4c7c2147e7

+ 1 - 1
configs/configs.sample.php

@@ -25,7 +25,7 @@ $tmp_config = [
         'redis' => [
             'host' => '192.168.2.220',
             'port' => 26379,
-            'passwd' => '',
+            'passwd' => '123456',
             'db' => 0,
             'overtime' => 1,
         ],

+ 5 - 0
datainf/logic/HttpServerOnlySet.php

@@ -96,6 +96,11 @@ class HttpServerOnlySet
             throw  new \Exception("连接redis失败 " . date("Y-m-d H:i:s"));
             return;
         }
+        if (!$this->redis->auth($this->redisconfig['passwd'])) {
+            throw  new \Exception("redis auth 失败 " . date("Y-m-d H:i:s"));
+            return;
+        }
+        $this->redis->select($this->redisconfig['db']);
         $this->redisTime = time();
         return $this->redis;
     }

+ 13 - 1
datainf/logic/HttpServerRedisToSql.php

@@ -73,7 +73,19 @@ class HttpServerRedisToSql
         $redisconfig = $this->redisonfig;
         go(function () use ($redisconfig) {
             $redis = new Swoole\Coroutine\Redis();
-            $redis->connect($redisconfig['host'], $redisconfig['port']);
+            $ret = $redis->connect($redisconfig['host'], $redisconfig['port']);
+            if (!$ret) {
+                echo "redis 连接失败!";
+                return;
+            }
+            if (!empty($redisconfig['passwd'])) {
+                $ret = $redis->auth($redisconfig['passwd']);
+                if (!$ret) {
+                    echo "redis auth 失败!";
+                    return;
+                }
+            }
+            $redis->select($redisconfig['db']);
 
             if ($redis->llen(self::SQLKEY) <= 0) {
                 return;

+ 6 - 9
datainf/logic/HttpServerSettelement.php

@@ -211,15 +211,7 @@ class HttpServerSettelement
             list($order_ids, $bettype, $settype, $game_code, $match_id, $change_status) = $this->requestpara($request, $response, $paras);
 
             if (empty($order_ids)) {
-                $needs_matchs = DB::table('money_buy_match')->where(['game_code' => $game_code, 'match_id' => $match_id])->count();
-                if ($needs_matchs <= 0) {
-                    $this->cgStatus($game_code, $match_id, $this->change_status);
-                    goto LABRETURN;
-                    return;
-                } else {
-                    throw  new \Exception('订单号不能为空!');
-                }
-                unset($needs_matchs);
+                goto LABRETURN;
             }
 
             if ($bettype == 1) {
@@ -243,6 +235,11 @@ class HttpServerSettelement
                 go(function () use ($data, $redisconfig) {
                     $redis = new Swoole\Coroutine\Redis();
                     $redis->connect($redisconfig['host'], $redisconfig['port']);
+                    if (!empty($redis['passwd'])) {
+                        $redis->auth($redis['passwd']);
+                    }
+                    $redis->select($redis['db']);
+
                     $redis->lpush(self::TASKQNUM, $data);
                     return;
                 });

+ 12 - 0
readme.txt

@@ -44,6 +44,18 @@ php bootRedisToSql.php
 
 
 
+
+
+
+ps -ef | grep  bootDbPoole | awk '{print $1}' | sort -n | head -n 1 |  xargs  kill
+ps -ef | grep  bootHttp | awk '{print $1}' | sort -n | head -n 1 |  xargs  kill
+ps -ef | grep  bootSetOnly | awk '{print $1}' | sort -n | head -n 1 |  xargs  kill
+ps -ef | grep  bootSettelementHttp | awk '{print $1}' | sort -n | head -n 1 |  xargs  kill
+ps -ef | grep  bootRedisToSql | awk '{print $1}' | sort -n | head -n 1 |  xargs  kill
+
+
+
+
 客户端调用:
 
 get: