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')) {