Skip to content

Commit

Permalink
Fixed the bug that cannot work on laravel 11.x (#17)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
huangdijia and huangdijia authored Mar 8, 2024
1 parent e3591f3 commit 1734c38
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/testing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand All @@ -68,3 +68,4 @@ jobs:
run: |
cd ${PROJECT_NAME}
php artisan horizon:list
cat /tmp/horizon.log
8 changes: 6 additions & 2 deletions src/Console/RestartCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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");
});
Expand Down

0 comments on commit 1734c38

Please sign in to comment.