File tree Expand file tree Collapse file tree 2 files changed +53
-0
lines changed Expand file tree Collapse file tree 2 files changed +53
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Laravel \Horizon \Console ;
4
+
5
+ use Illuminate \Console \Command ;
6
+ use Illuminate \Support \Str ;
7
+ use Laravel \Horizon \Contracts \SupervisorRepository ;
8
+ use Laravel \Horizon \MasterSupervisor ;
9
+ use Symfony \Component \Console \Attribute \AsCommand ;
10
+
11
+ #[AsCommand(name: 'horizon:supervisor-status ' )]
12
+ class SupervisorStatusCommand extends Command
13
+ {
14
+ /**
15
+ * The name and signature of the console command.
16
+ *
17
+ * @var string
18
+ */
19
+ protected $ signature = 'horizon:supervisor-status
20
+ {name : The name of the supervisor} ' ;
21
+
22
+ /**
23
+ * The console command description.
24
+ *
25
+ * @var string
26
+ */
27
+ protected $ description = 'Show the status for a given supervisor ' ;
28
+
29
+ /**
30
+ * Execute the console command.
31
+ *
32
+ * @param \Laravel\Horizon\Contracts\SupervisorRepository $supervisors
33
+ * @return void
34
+ */
35
+ public function handle (SupervisorRepository $ supervisors )
36
+ {
37
+ $ name = $ this ->argument ('name ' );
38
+
39
+ $ supervisorStatus = optional (collect ($ supervisors ->all ())->first (function ($ supervisor ) use ($ name ) {
40
+ return Str::startsWith ($ supervisor ->name , MasterSupervisor::basename ()) &&
41
+ Str::endsWith ($ supervisor ->name , $ name );
42
+ }))->status ;
43
+
44
+ if (is_null ($ supervisorStatus )) {
45
+ $ this ->components ->error ('Unable to find a supervisor with this name. ' );
46
+
47
+ return 1 ;
48
+ }
49
+
50
+ $ this ->components ->info ("{$ name } is {$ supervisorStatus }" );
51
+ }
52
+ }
Original file line number Diff line number Diff line change @@ -115,6 +115,7 @@ protected function registerCommands()
115
115
Console \PurgeCommand::class,
116
116
Console \StatusCommand::class,
117
117
Console \SupervisorCommand::class,
118
+ Console \SupervisorStatusCommand::class,
118
119
Console \SupervisorsCommand::class,
119
120
Console \TerminateCommand::class,
120
121
Console \TimeoutCommand::class,
You can’t perform that action at this time.
0 commit comments