mirror of
https://github.com/idanoo/php-resque.git
synced 2024-11-22 08:15:14 +00:00
avoid working with dirty worker ids
This commit is contained in:
parent
4700375d25
commit
5b24b471dc
@ -53,7 +53,7 @@ class Resque_Worker
|
|||||||
* @var Resque_Job Current job, if any, being processed by this worker.
|
* @var Resque_Job Current job, if any, being processed by this worker.
|
||||||
*/
|
*/
|
||||||
private $currentJob = null;
|
private $currentJob = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var int Process ID of child worker processes.
|
* @var int Process ID of child worker processes.
|
||||||
*/
|
*/
|
||||||
@ -95,7 +95,7 @@ class Resque_Worker
|
|||||||
*/
|
*/
|
||||||
public static function find($workerId)
|
public static function find($workerId)
|
||||||
{
|
{
|
||||||
if(!self::exists($workerId)) {
|
if(!self::exists($workerId) || false === strpos($workerId, ":")) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -447,12 +447,14 @@ class Resque_Worker
|
|||||||
$workerPids = $this->workerPids();
|
$workerPids = $this->workerPids();
|
||||||
$workers = self::all();
|
$workers = self::all();
|
||||||
foreach($workers as $worker) {
|
foreach($workers as $worker) {
|
||||||
list($host, $pid, $queues) = explode(':', (string)$worker, 3);
|
if (is_object($worker)) {
|
||||||
if($host != $this->hostname || in_array($pid, $workerPids) || $pid == getmypid()) {
|
list($host, $pid, $queues) = explode(':', (string)$worker, 3);
|
||||||
continue;
|
if($host != $this->hostname || in_array($pid, $workerPids) || $pid == getmypid()) {
|
||||||
}
|
continue;
|
||||||
$this->log('Pruning dead worker: ' . (string)$worker, self::LOG_VERBOSE);
|
}
|
||||||
$worker->unregisterWorker();
|
$this->log('Pruning dead worker: ' . (string)$worker, self::LOG_VERBOSE);
|
||||||
|
$worker->unregisterWorker();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user