Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
MetaGer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open-source
MetaGer
Commits
2f3aaae4
Commit
2f3aaae4
authored
5 years ago
by
Dominik Hebeler
Browse files
Options
Downloads
Patches
Plain Diff
workers now accept a socks5 configuration
parent
2f772526
No related branches found
No related tags found
1 merge request
!1502
Development
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
.env.example
+1
-1
1 addition, 1 deletion
.env.example
app/Jobs/Searcher.php
+13
-1
13 additions, 1 deletion
app/Jobs/Searcher.php
phpunit.xml
+1
-1
1 addition, 1 deletion
phpunit.xml
with
15 additions
and
3 deletions
.env.example
+
1
−
1
View file @
2f3aaae4
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
app/Jobs/Searcher.php
+
13
−
1
View file @
2f3aaae4
...
@@ -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
);
}
}
...
...
This diff is collapsed.
Click to expand it.
phpunit.xml
+
1
−
1
View file @
2f3aaae4
...
@@ -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>
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment