Commit 2f3aaae4 authored by Dominik Hebeler's avatar Dominik Hebeler

workers now accept a socks5 configuration

parent 2f772526
...@@ -7,7 +7,7 @@ APP_URL=http://localhost ...@@ -7,7 +7,7 @@ APP_URL=http://localhost
BROADCAST_DRIVER=log BROADCAST_DRIVER=log
CACHE_DRIVER=file CACHE_DRIVER=file
SESSION_DRIVER=file SESSION_DRIVER=file
QUEUE_DRIVER=sync QUEUE_CONNECTION=sync
REDIS_HOST=127.0.0.1 REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null REDIS_PASSWORD=null
......
...@@ -13,6 +13,7 @@ class Searcher implements ShouldQueue ...@@ -13,6 +13,7 @@ class Searcher implements ShouldQueue
use InteractsWithQueue, Queueable, SerializesModels; use InteractsWithQueue, Queueable, SerializesModels;
protected $name, $ch, $pid, $counter, $lastTime, $connectionInfo, $user, $password, $headers; protected $name, $ch, $pid, $counter, $lastTime, $connectionInfo, $user, $password, $headers;
protected $proxyhost, $proxyuser, $proxypassword;
# Each Searcher will shutdown after a specified time(s) or number of requests # Each Searcher will shutdown after a specified time(s) or number of requests
protected $MAX_REQUESTS = 100; protected $MAX_REQUESTS = 100;
# This value should always be below the retry_after value in config/queue.php # This value should always be below the retry_after value in config/queue.php
...@@ -41,6 +42,10 @@ class Searcher implements ShouldQueue ...@@ -41,6 +42,10 @@ class Searcher implements ShouldQueue
$this->user = $user; $this->user = $user;
$this->password = $password; $this->password = $password;
$this->headers = $headers; $this->headers = $headers;
$this->proxyhost = env("PROXY_HOST", "");
$this->proxyport = env("PROXY_PORT", "");
$this->proxyuser = env("PROXY_USER", "");
$this->proxypassword = env("PROXY_PASSWORD", "");
// Submit this worker to the Redis System // Submit this worker to the Redis System
Redis::expire($this->name, 5); Redis::expire($this->name, 5);
} }
...@@ -123,7 +128,7 @@ class Searcher implements ShouldQueue ...@@ -123,7 +128,7 @@ class Searcher implements ShouldQueue
* When a search engine needs more time to produce search results than the timeout of the MetaGer process, we won't even bother of spawning * When a search engine needs more time to produce search results than the timeout of the MetaGer process, we won't even bother of spawning
* more and more Searchers because they would just block free worker processes from serving the important engines which will give results in time. * more and more Searchers because they would just block free worker processes from serving the important engines which will give results in time.
**/ **/
if ($this->counter === 3 || getenv("QUEUE_DRIVER") === "sync") { if ($this->counter === 3 || getenv("QUEUE_CONNECTION") === "sync") {
# If the MetaGer process waits longer for the results than this Fetcher will probably need to fetch # If the MetaGer process waits longer for the results than this Fetcher will probably need to fetch
# Or if this engine is in the array of important engines which we will always try to serve # Or if this engine is in the array of important engines which we will always try to serve
Redis::set($this->name, "running"); Redis::set($this->name, "running");
...@@ -206,6 +211,13 @@ class Searcher implements ShouldQueue ...@@ -206,6 +211,13 @@ class Searcher implements ShouldQueue
CURLOPT_TIMEOUT => 10, CURLOPT_TIMEOUT => 10,
)); ));
if (!empty($this->proxyhost) && !empty($this->proxyport) && !empty($this->proxyuser) && !empty($this->proxypassword)) {
curl_setopt(CURLOPT_PROXY, $this->proxyhost);
curl_setopt(CURLOPT_PROXYUSERPWD, $this->proxyuser . ":" . $this->proxypassword);
curl_setopt(CURLOPT_PROXYPORT, $this->proxyport);
curl_setopt(CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
}
if ($this->user !== null && $this->password !== null) { if ($this->user !== null && $this->password !== null) {
curl_setopt($ch, CURLOPT_USERPWD, $this->user . ":" . $this->password); curl_setopt($ch, CURLOPT_USERPWD, $this->user . ":" . $this->password);
} }
......
...@@ -22,6 +22,6 @@ ...@@ -22,6 +22,6 @@
<env name="APP_ENV" value="testing"/> <env name="APP_ENV" value="testing"/>
<env name="CACHE_DRIVER" value="array"/> <env name="CACHE_DRIVER" value="array"/>
<env name="SESSION_DRIVER" value="array"/> <env name="SESSION_DRIVER" value="array"/>
<env name="QUEUE_DRIVER" value="sync"/> <env name="QUEUE_CONNECTION" value="sync"/>
</php> </php>
</phpunit> </phpunit>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment