Skip to content
This repository has been archived by the owner on Mar 23, 2023. It is now read-only.

Commit

Permalink
Merge pull request #49 from bar/resquestatus-getworkers
Browse files Browse the repository at this point in the history
Be explicit indicating that ResqueStatus::getWorkers() returns the active workers arguments (and not the workers).
  • Loading branch information
wa0x6e committed Jan 31, 2014
2 parents 365caa3 + 993bdac commit 34f9a7c
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions Console/Command/CakeResqueShell.php
Original file line number Diff line number Diff line change
Expand Up @@ -405,14 +405,14 @@ public function enqueueAt() {
public function tail() {
$logs = array();
$i = 1;
$workers = $this->ResqueStatus->getWorkers();
$workersArgs = $this->ResqueStatus->getWorkers();

foreach ($workers as $worker) {
if ($worker['log'] != '') {
$logs[] = $worker['log'];
foreach ($workersArgs as $workerArgs) {
if ($workerArgs['log'] != '') {
$logs[] = $workerArgs['log'];
}
if ($worker['Log']['handler'] == 'RotatingFile') {
$fileInfo = pathinfo($worker['Log']['target']);
if ($workerArgs['Log']['handler'] == 'RotatingFile') {
$fileInfo = pathinfo($workerArgs['Log']['target']);
$pattern = $fileInfo['dirname'] . DS . $fileInfo['filename'] . '-*' . (!empty($fileInfo['extension']) ? '.' . $fileInfo['extension'] : '');

$logs = array_merge($logs, glob($pattern));
Expand Down Expand Up @@ -874,14 +874,16 @@ protected function _sendSignal($title, $workers, $noWorkersMessage, $listTitle,
*/
public function load() {
$this->out('<info>' . __d('cake_resque', 'Loading predefined workers') . '</info>');

$debug = isset($this->params['debug']) ? $this->params['debug'] : false;
$queues = Configure::read('CakeResque.Queues');

if (Configure::read('CakeResque.Queues') == null) {
if ($queues === null) {
$this->out(' ' . __d('cake_resque', 'You have no configured workers to load.'));
} else {
foreach (Configure::read('CakeResque.Queues') as $queue) {
$queue['debug'] = $debug;
$this->start($queue);
foreach ($queues as $workerArgs) {
$workerArgs['debug'] = $debug;
$this->start($workerArgs);
}
}

Expand All @@ -901,22 +903,22 @@ public function load() {
* @see ResqueStatus\ResqueStatus::getWorkers()
*/
public function restart() {
$workers = $this->ResqueStatus->getWorkers();
$workersArgs = $this->ResqueStatus->getWorkers();

$this->params['all'] = true;
$this->stop();

$this->out('<info>' . __d('cake_resque', 'Restarting workers') . '</info>');
if (!empty($workers)) {
if (!empty($workersArgs)) {
$debug = $this->params['debug'];
$this->debug(__d('cake_resque', 'Found ' . count($workers) . ' workers to restart'));
$this->debug(__d('cake_resque', 'Found ' . count($workersArgs) . ' workers to restart'));

foreach ($workers as $worker) {
$worker['debug'] = $debug;
if (isset($worker['type']) && $worker['type'] === 'scheduler') {
$this->startScheduler($worker);
foreach ($workersArgs as $workerArgs) {
$workerArgs['debug'] = $debug;
if (isset($workerArgs['type']) && $workerArgs['type'] === 'scheduler') {
$this->startScheduler($workerArgs);
} else {
$this->start($worker);
$this->start($workerArgs);
}
}
$this->out('');
Expand Down

0 comments on commit 34f9a7c

Please sign in to comment.