From b322bd55c579275b26816251148aac8fe97808bf Mon Sep 17 00:00:00 2001 From: Jakub Onderka Date: Sat, 20 Nov 2021 14:41:19 +0100 Subject: [PATCH] fix: [CLI] Show error when calling methods for managing workers when SimpleBackgroundJobs are enabled --- app/Console/Command/AdminShell.php | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/app/Console/Command/AdminShell.php b/app/Console/Command/AdminShell.php index 6ccf9c64e..22e0dc77a 100644 --- a/app/Console/Command/AdminShell.php +++ b/app/Console/Command/AdminShell.php @@ -126,13 +126,6 @@ class AdminShell extends AppShell echo $this->Server->update($status) . PHP_EOL; } - public function restartWorkers() - { - $this->ConfigLoad->execute(); - $this->Server->restartWorkers(); - echo PHP_EOL . 'Workers restarted.' . PHP_EOL; - } - public function updateAfterPull() { $this->ConfigLoad->execute(); @@ -156,8 +149,23 @@ class AdminShell extends AppShell } } + public function restartWorkers() + { + if (Configure::read('SimpleBackgroundJobs.enabled')) { + $this->error('This method does nothing when SimpleBackgroundJobs are enabled.'); + } + + $this->ConfigLoad->execute(); + $this->Server->restartWorkers(); + echo PHP_EOL . 'Workers restarted.' . PHP_EOL; + } + public function restartWorker() { + if (Configure::read('SimpleBackgroundJobs.enabled')) { + $this->error('This method does nothing when SimpleBackgroundJobs are enabled.'); + } + $this->ConfigLoad->execute(); if (empty($this->args[0]) || !is_numeric($this->args[0])) { die('Usage: ' . $this->Server->command_line_functions['worker_management_tasks']['data']['Restart a worker'] . PHP_EOL); @@ -180,6 +188,10 @@ class AdminShell extends AppShell public function killWorker() { + if (Configure::read('SimpleBackgroundJobs.enabled')) { + $this->error('This method does nothing when SimpleBackgroundJobs are enabled.'); + } + $this->ConfigLoad->execute(); if (empty($this->args[0]) || !is_numeric($this->args[0])) { die('Usage: ' . $this->Server->command_line_functions['worker_management_tasks']['data']['Kill a worker'] . PHP_EOL); @@ -197,6 +209,10 @@ class AdminShell extends AppShell public function startWorker() { + if (Configure::read('SimpleBackgroundJobs.enabled')) { + $this->error('This method does nothing when SimpleBackgroundJobs are enabled.'); + } + $this->ConfigLoad->execute(); if (empty($this->args[0])) { die('Usage: ' . $this->Server->command_line_functions['worker_management_tasks']['data']['Start a worker'] . PHP_EOL);