summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOmar Roth <omarroth@hotmail.com>2018-02-05 17:57:53 -0600
committerOmar Roth <omarroth@hotmail.com>2018-02-05 17:57:53 -0600
commitd1a2b193aab9be8183db310cd405021d99af164c (patch)
treeae50a16b465f89e563ee5a7433315538dcb40570
parent25434c676c449ca4748baa06e75fa973f78cfd23 (diff)
downloadinvidious-d1a2b193aab9be8183db310cd405021d99af164c.tar.gz
invidious-d1a2b193aab9be8183db310cd405021d99af164c.tar.bz2
invidious-d1a2b193aab9be8183db310cd405021d99af164c.zip
Change client timeout and make sure there is always a client available
-rw-r--r--src/invidious.cr16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/invidious.cr b/src/invidious.cr
index 18613ffe..53721d7b 100644
--- a/src/invidious.cr
+++ b/src/invidious.cr
@@ -47,10 +47,10 @@ CONTEXT.add_options(
OpenSSL::SSL::Options::NO_SSL_V2 |
OpenSSL::SSL::Options::NO_SSL_V3
)
-pool = Deque.new((threads * 1.2).to_i) do
+pool = Deque.new((threads * 1.2 + 1).to_i) do
client = HTTP::Client.new(URL, CONTEXT)
- client.read_timeout = 5.seconds
- client.connect_timeout = 5.seconds
+ client.read_timeout = 10.seconds
+ client.connect_timeout = 10.seconds
client
end
@@ -75,8 +75,8 @@ threads.times do
if rand(300) < 1
client = HTTP::Client.new(URL, CONTEXT)
- client.read_timeout = 5.seconds
- client.connect_timeout = 5.seconds
+ client.read_timeout = 10.seconds
+ client.connect_timeout = 10.seconds
pool << client
end
@@ -88,8 +88,8 @@ threads.times do
rescue ex
io << id << " : " << ex << "\n"
client = HTTP::Client.new(URL, CONTEXT)
- client.read_timeout = 5.seconds
- client.connect_timeout = 5.seconds
+ client.read_timeout = 10.seconds
+ client.connect_timeout = 10.seconds
pool << client
next
ensure
@@ -198,7 +198,7 @@ get "/watch" do |env|
engagement = ((video.dislikes.to_f + video.likes.to_f)/video.views * 100)
if video.likes > 0 || video.dislikes > 0
- calculated_rating = (video.likes.to_f/(video.likes.to_f + video.dislikes.to_f) * 4 + 1)
+ calculated_rating = (video.likes.to_f/(video.likes.to_f + video.dislikes.to_f) * 4 + 1)
else
calculated_rating = 0.0
end