wesmiler %!s(int64=2) %!d(string=hai) anos
pai
achega
71289ebbb0
Modificáronse 1 ficheiros con 4 adicións e 3 borrados
  1. 4 3
      app/Console/Commands/SocketServer.php

+ 4 - 3
app/Console/Commands/SocketServer.php

@@ -66,7 +66,7 @@ class SocketServer extends Command
     {
         try {
             //创建websocket服务器对象,监听0.0.0.0:7104端口
-            $this->ws = new \Swoole\WebSocket\Server("0.0.0.0", env('SOCKET_PORT', '6630'));
+            $this->ws = new \Swoole\WebSocket\Server("0.0.0.0", env('SOCKET_PORT', '6530'));
 
             //监听WebSocket连接打开事件
             $this->ws->on('open', [$this, 'open']);
@@ -362,10 +362,11 @@ class SocketServer extends Command
     {
         if ($this->ws) {
             // 直接杀
+            $port = env('SOCKET_PORT', '6530');
             if(function_exists('exec')){
-                exec('pkill -9 swoole:socket start');
+                exec('pid=$(lsof -F p  -i:'.$port.' | cut -b 2-) &&  pkill -9 $pid');
             }
-
+            
             echo "socket stop...\n";
             $date = date('Y-m-d H:i:s');
             $this->info("【{$date}】Socket:停止运行服务");