mirror of
https://github.com/idanoo/php-resque.git
synced 2024-11-22 00:11:53 +00:00
Merge pull request #158 from ruudk/default-logger
Set Resque_Log in constructor
This commit is contained in:
commit
055587abf0
@ -49,6 +49,36 @@ class Resque_Worker
|
|||||||
*/
|
*/
|
||||||
private $child = null;
|
private $child = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return all workers known to Resque as instantiated instances.
|
* Return all workers known to Resque as instantiated instances.
|
||||||
* @return array
|
* @return array
|
||||||
@ -107,34 +137,6 @@ class Resque_Worker
|
|||||||
$this->id = $workerId;
|
$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 primary loop for a worker which when called on an instance starts
|
||||||
* the worker's life cycle.
|
* the worker's life cycle.
|
||||||
|
Loading…
Reference in New Issue
Block a user