Kaynağa Gözat

gg开始,配置

lizhen_gitee 1 yıl önce
ebeveyn
işleme
da20ac0685

+ 5 - 4
application/chat/Events.php

@@ -35,7 +35,7 @@ class Events
 
         App::initCommon();
 
-        $info = Db::name('test')->insertGetId(['msg'=>'onWorkerStart','datetime'=>date('Y-m-d H:i:s')]);
+        $info = Db::name('gateway_test')->insertGetId(['msg'=>'onWorkerStart','datetime'=>date('Y-m-d H:i:s')]);
     }
 
     /**
@@ -47,7 +47,7 @@ class Events
     {
          echo $message.PHP_EOL;
          file_put_contents('1.json',$message.PHP_EOL,FILE_APPEND);
-         $info = Db::name('test')->insertGetId(['msg'=>'[msg]'.$message,'datetime'=>date('Y-m-d H:i:s')]);
+         $info = Db::name('gateway_test')->insertGetId(['msg'=>'[msg]'.$message,'datetime'=>date('Y-m-d H:i:s')]);
          return;
 
         /* $message = json_decode($message,true);
@@ -92,7 +92,8 @@ class Events
     private static function changestatus($message){
         //dump($message);
         if(isset($message['uid']) && isset($message['value'])){
-            redis_set($message['uid'],$message['value']);
+            $redis = newredis();
+            $redis->set('gg_matching_uid_'.$message['uid'], $message['value'], null);
         }
         return;
     }
@@ -131,7 +132,7 @@ class Events
     }
 
     public static function onWorkerStop(){
-        $info = Db::name('test')->insertGetId(['msg'=>'onWorkerStop','datetime'=>date('Y-m-d H:i:s')]);
+        $info = Db::name('gateway_test')->insertGetId(['msg'=>'onWorkerStop','datetime'=>date('Y-m-d H:i:s')]);
     }
   
 }

+ 14 - 0
application/common.php

@@ -10,3 +10,17 @@
 // +----------------------------------------------------------------------
 
 // 应用公共文件
+
+function newredis(){
+    $redis = new Redis();
+    $redisconfig = config("redis");
+    $redis->connect($redisconfig["host"], $redisconfig["port"]);
+    if ($redisconfig['redis_pwd']) {
+        $redis->auth(config('redis_pwd'));
+    }
+    if($redisconfig['redis_selectdb'] > 0){
+        $redis->select(config('redis_selectdb'));
+    }
+    return $redis;
+}
+

+ 10 - 0
application/config.php

@@ -240,4 +240,14 @@ return [
         'var_page'  => 'page',
         'list_rows' => 15,
     ],
+
+
+    'redis'                  => [
+        // 主机
+        'host'     => '121.5.123.166',
+        // 端口
+        'port'      => 6379,
+        'redis_pwd' => 123456,
+        'redis_selectdb' => 8,
+    ],
 ];

+ 6 - 6
application/database.php

@@ -15,21 +15,21 @@ return [
     // 服务器地址
     'hostname'        => '121.5.123.166',
     // 数据库名
-    'database'        => 'gateway',
+    'database'        => 'ggvoice',
     // 用户名
-    'username'        => 'gateway',
+    'username'        => 'ggvoice',
     // 密码
-    'password'        => 'gateway',
+    'password'        => 'skmemBwYjA3fPxSk',
     // 端口
-    'hostport'        => '',
+    'hostport'        => '3306',
     // 连接dsn
     'dsn'             => '',
     // 数据库连接参数
     'params'          => [],
     // 数据库编码默认采用utf8
-    'charset'         => 'utf8',
+    'charset'         => 'utf8mb4',
     // 数据库表前缀
-    'prefix'          => '',
+    'prefix'          => 'hx_',
     // 数据库调试模式
     'debug'           => true,
     // 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器)

+ 1 - 1
gitpull.sh

@@ -1,4 +1,4 @@
 sudo -uroot git reset --hard;
 sudo -uroot git pull;
-sudo -uroot chown -R www:www /www/wwwroot/test_gatewayworker;
+sudo -uroot chown -R www:www /www/wwwroot/ggyuyin_gatewayworker;
 sudo -uroot chmod -R 777 *;

+ 0 - 8
thinkphp/helper.php

@@ -350,14 +350,6 @@ if (!function_exists('cache')) {
      * @param string    $tag 缓存标签
      * @return mixed
      */
-    function redis_set($name,$value,$expire = null){
-        $cache = Cache::connect(['type'=>'Redis']);
-        return $cache->set('mt_matching_uid_'.$name, $value, $expire);
-    }
-    function redis_get($name){
-        $cache = Cache::connect(['type'=>'Redis']);
-        return $cache->get('mt_matching_uid_'.$name);
-    }
     function cache($name, $value = '', $options = null, $tag = null)
     {
         if (is_array($options)) {