Skip to content
Snippets Groups Projects
Commit 23d10c3e authored by Dominik Hebeler's avatar Dominik Hebeler
Browse files

Fetcher erhöhen ihre Anzahl nicht mehr selbstständig

parent 1cecd9b3
No related branches found
No related tags found
2 merge requests!859Development,!833Fetcher erhöhen ihre Anzahl nicht mehr selbstständig
...@@ -46,6 +46,7 @@ class Searcher implements ShouldQueue ...@@ -46,6 +46,7 @@ class Searcher implements ShouldQueue
// This Searches is freshly called so we need to initialize the curl handle $ch // This Searches is freshly called so we need to initialize the curl handle $ch
$this->ch = $this->initCurlHandle(); $this->ch = $this->initCurlHandle();
$this->counter = 0; // Counts the number of answered jobs $this->counter = 0; // Counts the number of answered jobs
$lastJob = microtime(true);
while(true){ while(true){
// Update the expire // Update the expire
Redis::expire($this->name, 5); Redis::expire($this->name, 5);
...@@ -59,15 +60,14 @@ class Searcher implements ShouldQueue ...@@ -59,15 +60,14 @@ class Searcher implements ShouldQueue
// The mission can be empty when blpop hit the timeout // The mission can be empty when blpop hit the timeout
if(empty($mission)){ if(empty($mission)){
// In that case it should be safe to simply exit this job // In that case it should be safe to simply exit this job
break; if(((microtime(true) - $lastJob) ) > 300)
break;
else
continue;
}else{ }else{
$mission = $mission[1]; $mission = $mission[1];
$this->counter++; $this->counter++;
// A running Searcher checks whether more of it are needed to properly work on the $lastJob = microtime(true);
// Queue without delay
if(getenv("QUEUE_DRIVER") !== "sync" && intval(Redis::llen($this->name . ".queue")) > 1){
$this->dispatch(new Searcher($this->name));
}
} }
// The mission is a String which can be divided to retrieve two informations: // The mission is a String which can be divided to retrieve two informations:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment