From cdc5c3f357eed309ec4affccb40583ed1282d45a Mon Sep 17 00:00:00 2001 From: Ruud Kamphuis Date: Fri, 20 Dec 2013 12:21:52 +0100 Subject: [PATCH 1/2] Set Resque_Log in constructor --- lib/Resque/Worker.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/Resque/Worker.php b/lib/Resque/Worker.php index d94aef5..d08504c 100644 --- a/lib/Resque/Worker.php +++ b/lib/Resque/Worker.php @@ -49,6 +49,11 @@ class Resque_Worker */ private $child = null; + public function __construct() + { + $this->logger = new Resque_Log(); + } + /** * Return all workers known to Resque as instantiated instances. * @return array From aeabb5bb200c1ec91b42209282129428cb9b921c Mon Sep 17 00:00:00 2001 From: Ruud Kamphuis Date: Fri, 20 Dec 2013 12:24:24 +0100 Subject: [PATCH 2/2] Constructor on top with default logger --- lib/Resque/Worker.php | 55 ++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 29 deletions(-) diff --git a/lib/Resque/Worker.php b/lib/Resque/Worker.php index d08504c..379b853 100644 --- a/lib/Resque/Worker.php +++ b/lib/Resque/Worker.php @@ -49,9 +49,34 @@ class Resque_Worker */ private $child = null; - public function __construct() + /** + * Instantiate a new worker, given a list of queues that it should be working + * on. The list of queues should be supplied in the priority that they should + * be checked for jobs (first come, first served) + * + * Passing a single '*' allows the worker to work on all queues in alphabetical + * order. You can easily add new queues dynamically and have them worked on using + * this method. + * + * @param string|array $queues String with a single queue name, array with multiple. + */ + public function __construct($queues) { $this->logger = new Resque_Log(); + + if(!is_array($queues)) { + $queues = array($queues); + } + + $this->queues = $queues; + if(function_exists('gethostname')) { + $hostname = gethostname(); + } + else { + $hostname = php_uname('n'); + } + $this->hostname = $hostname; + $this->id = $this->hostname . ':'.getmypid() . ':' . implode(',', $this->queues); } /** @@ -112,34 +137,6 @@ class Resque_Worker $this->id = $workerId; } - /** - * Instantiate a new worker, given a list of queues that it should be working - * on. The list of queues should be supplied in the priority that they should - * be checked for jobs (first come, first served) - * - * Passing a single '*' allows the worker to work on all queues in alphabetical - * order. You can easily add new queues dynamically and have them worked on using - * this method. - * - * @param string|array $queues String with a single queue name, array with multiple. - */ - public function __construct($queues) - { - if(!is_array($queues)) { - $queues = array($queues); - } - - $this->queues = $queues; - if(function_exists('gethostname')) { - $hostname = gethostname(); - } - else { - $hostname = php_uname('n'); - } - $this->hostname = $hostname; - $this->id = $this->hostname . ':'.getmypid() . ':' . implode(',', $this->queues); - } - /** * The primary loop for a worker which when called on an instance starts * the worker's life cycle.