From 1734c38bb0ab1358cd807e182f4700152d87354a Mon Sep 17 00:00:00 2001 From: Deeka Wong Date: Sat, 9 Mar 2024 00:24:43 +0800 Subject: [PATCH] Fixed the bug that cannot work on laravel 11.x (#17) * Fixed the bug that cannot work on laravel 11.x * Update Horizon logging in testing.yaml --------- Co-authored-by: Deeka Wong <8337659+huangdijia@users.noreply.github.com> --- .github/workflows/testing.yaml | 3 ++- src/Console/RestartCommand.php | 8 ++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/testing.yaml b/.github/workflows/testing.yaml index 2e712d7..3b70a0b 100644 --- a/.github/workflows/testing.yaml +++ b/.github/workflows/testing.yaml @@ -53,7 +53,7 @@ jobs: - name: Booting Horizon run: | cd ${PROJECT_NAME} - php artisan horizon & + php artisan horizon > /tmp/horizon.log & sleep 3 - name: Checking Horizon(running) run: | @@ -68,3 +68,4 @@ jobs: run: | cd ${PROJECT_NAME} php artisan horizon:list + cat /tmp/horizon.log diff --git a/src/Console/RestartCommand.php b/src/Console/RestartCommand.php index cf5ecc2..f24318b 100644 --- a/src/Console/RestartCommand.php +++ b/src/Console/RestartCommand.php @@ -37,12 +37,16 @@ class RestartCommand extends Command */ public function handle() { + /** @var MasterSupervisorRepository $repository */ $repository = $this->laravel->make(MasterSupervisorRepository::class); $masters = $repository->all(); - collect($masters)->each(function ($master) { + $env = app('config')['app.env'] ?? 'local'; + $connection = app('config')['horizon.environments.' . $env . '.supervisor-horizon-restart.connection'] ?? 'redis'; + + collect($masters)->each(function ($master) use ($connection) { $queue = Str::substr($master->name, 0, -5); - HorizonRestartJob::dispatch()->onQueue($queue); + HorizonRestartJob::dispatch()->onQueue($queue)->onConnection($connection); $this->info("Server [{$queue}] terminated"); });