From 2bc4b637c499eeb14a47f03f6fba0beb2b0d3575 Mon Sep 17 00:00:00 2001 From: Lonny Kapelushnik Date: Thu, 20 Jun 2019 13:00:48 -0400 Subject: [PATCH] Fixes laravel/horizon#618 --- .../RedisSupervisorRepository.php | 2 +- .../MasterSupervisorControllerTest.php | 34 +++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/Repositories/RedisSupervisorRepository.php b/src/Repositories/RedisSupervisorRepository.php index f0a71f80..ca83432c 100644 --- a/src/Repositories/RedisSupervisorRepository.php +++ b/src/Repositories/RedisSupervisorRepository.php @@ -117,7 +117,7 @@ public function update(Supervisor $supervisor) $pipe->hmset( 'supervisor:'.$supervisor->name, [ 'name' => $supervisor->name, - 'master' => explode(':', $supervisor->name)[0], + 'master' => implode(':',explode(':', $supervisor->name, -1)), 'pid' => $supervisor->pid(), 'status' => $supervisor->working ? 'running' : 'paused', 'processes' => $processes, diff --git a/tests/Controller/MasterSupervisorControllerTest.php b/tests/Controller/MasterSupervisorControllerTest.php index a835b62d..b672c8d7 100644 --- a/tests/Controller/MasterSupervisorControllerTest.php +++ b/tests/Controller/MasterSupervisorControllerTest.php @@ -61,4 +61,38 @@ public function test_master_supervisor_listing_with_supervisors() ], ]); } + + public function test_master_supervisor_with_custom_name_listing_with_supervisors() + { + $master = new MasterSupervisor; + $master->name = 'risa:production'; + resolve(MasterSupervisorRepository::class)->update($master); + + $master2 = new MasterSupervisor; + $master2->name = 'risa:production-2'; + resolve(MasterSupervisorRepository::class)->update($master2); + + $supervisor = new Supervisor(new SupervisorOptions('risa:production:name', 'redis')); + resolve(SupervisorRepository::class)->update($supervisor); + + $response = $this->actingAs(new Fakes\User)->get('/horizon/api/masters'); + + $response->assertJson([ + 'risa:production' => [ + 'name' => 'risa:production', + 'status' => 'running', + 'supervisors' => [ + [ + 'name' => 'risa:production:name', + 'master' => 'risa:production', + 'status' => 'running', + 'processes' => ['redis:default' => 0], + ], + ], + ], + 'risa:production-2' => [ + 'supervisors' => [], + ], + ]); + } }