From 2a3dcd8537b55536ca7594d265760efcc01fca27 Mon Sep 17 00:00:00 2001 From: Daniel Mason Date: Sun, 27 May 2018 14:52:05 +1200 Subject: [PATCH] Clean up bin/resque file --- bin/resque | 56 +++++++++++++++++++++++++----------------------------- 1 file changed, 26 insertions(+), 30 deletions(-) diff --git a/bin/resque b/bin/resque index 1d60485..421ce33 100755 --- a/bin/resque +++ b/bin/resque @@ -2,12 +2,12 @@ 1) { +if (!empty($COUNT) && $COUNT > 1) { $count = $COUNT; } $PREFIX = getenv('PREFIX'); -if(!empty($PREFIX)) { - $logger->log(Psr\Log\LogLevel::INFO, 'Prefix set to {prefix}', array('prefix' => $PREFIX)); +if (!empty($PREFIX)) { + $logger->log(Psr\Log\LogLevel::INFO, 'Prefix set to {prefix}', ['prefix' => $PREFIX]); Resque_Redis::prefix($PREFIX); } -if($count > 1) { - for($i = 0; $i < $count; ++$i) { +if ($count > 1) { + for ($i = 0; $i < $count; ++$i) { $pid = Resque::fork(); - if($pid === false || $pid === -1) { - $logger->log(Psr\Log\LogLevel::EMERGENCY, 'Could not fork worker {count}', array('count' => $i)); + if ($pid === false || $pid === -1) { + $logger->log(Psr\Log\LogLevel::EMERGENCY, 'Could not fork worker {count}', ['count' => $i]); die(); - } - // Child, start the worker - else if(!$pid) { + } elseif (!$pid) { + // Child, start the worker $queues = explode(',', $QUEUE); $worker = new Resque_Worker($queues); $worker->setLogger($logger); - $logger->log(Psr\Log\LogLevel::NOTICE, 'Starting worker {worker}', array('worker' => $worker)); + $logger->log(Psr\Log\LogLevel::NOTICE, 'Starting worker {worker}', ['worker' => $worker]); $worker->work($interval, $BLOCKING); break; } } -} -// Start a single worker -else { +} else { + // Start a single worker $queues = explode(',', $QUEUE); $worker = new Resque_Worker($queues); $worker->setLogger($logger); @@ -120,10 +117,9 @@ else { $PIDFILE = getenv('PIDFILE'); if ($PIDFILE) { file_put_contents($PIDFILE, getmypid()) or - die('Could not write PID information to ' . $PIDFILE); + die('Could not write PID information to ' . $PIDFILE); } - $logger->log(Psr\Log\LogLevel::NOTICE, 'Starting worker {worker}', array('worker' => $worker)); + $logger->log(Psr\Log\LogLevel::NOTICE, 'Starting worker {worker}', ['worker' => $worker]); $worker->work($interval, $BLOCKING); } -?>