diff --git a/apps/daemon/commands/SingleCommand.php b/apps/daemon/commands/SingleCommand.php index 30525cc8..25364186 100644 --- a/apps/daemon/commands/SingleCommand.php +++ b/apps/daemon/commands/SingleCommand.php @@ -41,7 +41,7 @@ public function startWork() { try { $this->work(); - } catch (\Exception $e) { + } catch (\Throwable $e) { // 处理异常 Error::handleException($e); // 休息一会,避免 CPU 出现 100% diff --git a/apps/websocketd/commands/ServiceCommand.php b/apps/websocketd/commands/ServiceCommand.php index 5dbd5460..7c8b4f8d 100644 --- a/apps/websocketd/commands/ServiceCommand.php +++ b/apps/websocketd/commands/ServiceCommand.php @@ -150,7 +150,7 @@ public function onOpen(\Swoole\WebSocket\Server $webSocket, $fd, \mix\http\Reque if ($type == 'message') { $webSocket->push($fd, $message); } - } catch (\Exception $e) { + } catch (\Throwable $e) { // 处理异常 Error::handleException($e); } @@ -170,7 +170,7 @@ public function onOpen(\Swoole\WebSocket\Server $webSocket, $fd, \mix\http\Reque // 订阅该用户id的消息队列 $channels[] = 'emit_to_' . $userinfo['uid']; call_user_func_array([$client, 'subscribe'], $channels); - } catch (\Exception $e) { + } catch (\Throwable $e) { // 处理异常 Error::handleException($e); // 关闭 WS 连接