From d36b29cff58cb9982dfb5efd01bad2d35a3ad3cb Mon Sep 17 00:00:00 2001 From: Matthew Frieswyk Date: Mon, 24 Jun 2024 00:43:24 -0400 Subject: [PATCH 1/4] Create status command for individual supervisors --- src/Console/StatusSupervisorCommand.php | 51 +++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 src/Console/StatusSupervisorCommand.php diff --git a/src/Console/StatusSupervisorCommand.php b/src/Console/StatusSupervisorCommand.php new file mode 100644 index 00000000..9a37bfe1 --- /dev/null +++ b/src/Console/StatusSupervisorCommand.php @@ -0,0 +1,51 @@ +argument('name'); + $supervisorStatus = optional(collect($supervisors->all())->first(function ($supervisor) use ($name) { + return Str::startsWith($supervisor->name, MasterSupervisor::basename()) + && Str::endsWith($supervisor->name, $name); + }))->status; + + if (is_null($supervisorStatus)) { + $this->components->error("Failed to find a supervisor with this name: {$name}"); + + return 1; + } + + $this->components->info("{$name} is {$supervisorStatus}"); + } +} From 72d398aba9fc0f1abb6af3be3c9705c3670139b2 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Thu, 27 Jun 2024 10:57:40 +0200 Subject: [PATCH 2/4] formatting --- ...sorCommand.php => SupervisorStatusCommand.php} | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) rename src/Console/{StatusSupervisorCommand.php => SupervisorStatusCommand.php} (72%) diff --git a/src/Console/StatusSupervisorCommand.php b/src/Console/SupervisorStatusCommand.php similarity index 72% rename from src/Console/StatusSupervisorCommand.php rename to src/Console/SupervisorStatusCommand.php index 9a37bfe1..c311dcfb 100644 --- a/src/Console/StatusSupervisorCommand.php +++ b/src/Console/SupervisorStatusCommand.php @@ -8,7 +8,7 @@ use Laravel\Horizon\MasterSupervisor; use Symfony\Component\Console\Attribute\AsCommand; -#[AsCommand(name: 'horizon:pause-supervisor')] +#[AsCommand(name: 'horizon:supervisor-status')] class StatusSupervisorCommand extends Command { /** @@ -16,15 +16,15 @@ class StatusSupervisorCommand extends Command * * @var string */ - protected $signature = 'horizon:status-supervisor - {name : The name of the supervisor to show status}'; + protected $signature = 'horizon:supervisor-status + {name : The name of the supervisor}'; /** * The console command description. * * @var string */ - protected $description = 'Show status for a supervisor'; + protected $description = 'Show the status for a given supervisor'; /** * Execute the console command. @@ -35,13 +35,14 @@ class StatusSupervisorCommand extends Command public function handle(SupervisorRepository $supervisors) { $name = $this->argument('name'); + $supervisorStatus = optional(collect($supervisors->all())->first(function ($supervisor) use ($name) { - return Str::startsWith($supervisor->name, MasterSupervisor::basename()) - && Str::endsWith($supervisor->name, $name); + return Str::startsWith($supervisor->name, MasterSupervisor::basename()) && + Str::endsWith($supervisor->name, $name); }))->status; if (is_null($supervisorStatus)) { - $this->components->error("Failed to find a supervisor with this name: {$name}"); + $this->components->error('Failed to find a supervisor with this name'); return 1; } From c77cd726dfec23d9083d6e44086989447c84ed4e Mon Sep 17 00:00:00 2001 From: Matthew Frieswyk Date: Sun, 11 Aug 2024 15:42:59 -0400 Subject: [PATCH 3/4] Rename and register command --- src/Console/SupervisorStatusCommand.php | 2 +- src/HorizonServiceProvider.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Console/SupervisorStatusCommand.php b/src/Console/SupervisorStatusCommand.php index c311dcfb..3d270251 100644 --- a/src/Console/SupervisorStatusCommand.php +++ b/src/Console/SupervisorStatusCommand.php @@ -9,7 +9,7 @@ use Symfony\Component\Console\Attribute\AsCommand; #[AsCommand(name: 'horizon:supervisor-status')] -class StatusSupervisorCommand extends Command +class SupervisorStatusCommand extends Command { /** * The name and signature of the console command. diff --git a/src/HorizonServiceProvider.php b/src/HorizonServiceProvider.php index 3f00a45e..2bb89730 100644 --- a/src/HorizonServiceProvider.php +++ b/src/HorizonServiceProvider.php @@ -115,6 +115,7 @@ protected function registerCommands() Console\PurgeCommand::class, Console\StatusCommand::class, Console\SupervisorCommand::class, + Console\SupervisorStatusCommand::class, Console\SupervisorsCommand::class, Console\TerminateCommand::class, Console\TimeoutCommand::class, From 2f01d7d3e3ebf2ca7d68664de4a20f4f090d4090 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Tue, 13 Aug 2024 13:18:12 -0500 Subject: [PATCH 4/4] Update SupervisorStatusCommand.php --- src/Console/SupervisorStatusCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Console/SupervisorStatusCommand.php b/src/Console/SupervisorStatusCommand.php index 3d270251..48909e84 100644 --- a/src/Console/SupervisorStatusCommand.php +++ b/src/Console/SupervisorStatusCommand.php @@ -42,7 +42,7 @@ public function handle(SupervisorRepository $supervisors) }))->status; if (is_null($supervisorStatus)) { - $this->components->error('Failed to find a supervisor with this name'); + $this->components->error('Unable to find a supervisor with this name.'); return 1; }