From 9fb07ab4380f0a66ecb469052f9368789d658ef2 Mon Sep 17 00:00:00 2001 From: "iVampireSP.com" Date: Wed, 8 Feb 2023 14:00:04 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9B=20=E9=9B=86=E7=BE=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Support/ClusterSupport.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/Support/ClusterSupport.php b/app/Support/ClusterSupport.php index cb679c4..7051da3 100644 --- a/app/Support/ClusterSupport.php +++ b/app/Support/ClusterSupport.php @@ -23,7 +23,7 @@ public static function isSlave(): bool return config('settings.node.type') === 'slave'; } - public static function publish($event, $data = []): void + public static function publish($event, $data = [], $register = true): void { /** @noinspection PhpUndefinedMethodInspection */ Redis::publish('cluster_ready', json_encode([ @@ -37,7 +37,9 @@ public static function publish($event, $data = []): void 'data' => $data, ])); - self::registerThisNode(false); + if ($register) { + self::registerThisNode(false); + } } public static function registerThisNode($report = true): void @@ -75,6 +77,7 @@ public static function listen(string|array $events, callable $callback, bool $ig ini_set('default_socket_timeout', -1); Redis::subscribe('cluster_ready', function ($message) use ($events, $callback, $ignore_self) { + echo $message; $message = json_decode($message, true); if ($ignore_self && $message['node']['id'] === config('settings.node.id')) {