wesmiler 2 лет назад
Родитель
Сommit
79962500bd
1 измененных файлов с 4 добавлено и 0 удалено
  1. 4 0
      app/Console/Commands/SocketServer.php

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

@@ -98,6 +98,10 @@ class SocketServer extends Command
     public function open($ws, $request)
     {
         $date = date('Y-m-d H:i:s');
+        $logFile = '/storage/logs/swoole-task-'.date('Y-m-d', time() - 86400).'.log';
+        if(file_exists(base_path().$logFile)){
+            unlink(base_path().$logFile);
+        }
         $this->ws->push($request->fd, json_encode(['success' => 'true', 'op' => 'conn', 'message' => '连接成功', 'fd' => $request->fd], 256));
         $this->info("【{$date}】Socket:客户端【{$request->fd}】连接成功");
     }