mirror of
https://git.nadeko.net/Fijxu/invidious.git
synced 2026-02-14 04:26:29 +00:00
Add RefreshChannelsJob traces
Traces can be enabled with `-l trace`. The problem with subscriptions is that sometimes requests to YouTube never finish. As soon as that happens `channel-threads` times subscriptions stop being refreshed. This is most likely a problem with the lsquick bindings.
This commit is contained in:
@@ -20,18 +20,23 @@ class Invidious::Jobs::RefreshChannelsJob < Invidious::Jobs::BaseJob
|
||||
id = rs.read(String)
|
||||
|
||||
if active_fibers >= lim_fibers
|
||||
logger.trace("RefreshChannelsJob: Fiber limit reached, waiting...")
|
||||
if active_channel.receive
|
||||
logger.trace("RefreshChannelsJob: Fiber limit ok, continuing")
|
||||
active_fibers -= 1
|
||||
end
|
||||
end
|
||||
|
||||
logger.trace("RefreshChannelsJob: #{id} : Spawning fiber")
|
||||
active_fibers += 1
|
||||
spawn do
|
||||
begin
|
||||
logger.trace("RefreshChannelsJob: Fetching channel #{id}")
|
||||
channel = fetch_channel(id, db, config.full_refresh)
|
||||
logger.trace("RefreshChannelsJob: #{id} fiber : Fetching channel")
|
||||
channel = fetch_channel(id, db, logger, config.full_refresh)
|
||||
|
||||
lim_fibers = max_fibers
|
||||
|
||||
logger.trace("RefreshChannelsJob: #{id} fiber : Updating DB")
|
||||
db.exec("UPDATE channels SET updated = $1, author = $2, deleted = false WHERE id = $3", Time.utc, channel.author, id)
|
||||
rescue ex
|
||||
logger.error("RefreshChannelsJob: #{id} : #{ex.message}")
|
||||
@@ -39,7 +44,7 @@ class Invidious::Jobs::RefreshChannelsJob < Invidious::Jobs::BaseJob
|
||||
db.exec("UPDATE channels SET updated = $1, deleted = true WHERE id = $2", Time.utc, id)
|
||||
else
|
||||
lim_fibers = 1
|
||||
logger.error("RefreshChannelsJob: #{id} : backing off for #{backoff}s")
|
||||
logger.error("RefreshChannelsJob: #{id} fiber : backing off for #{backoff}s")
|
||||
sleep backoff
|
||||
if backoff < 1.days
|
||||
backoff += backoff
|
||||
@@ -47,13 +52,15 @@ class Invidious::Jobs::RefreshChannelsJob < Invidious::Jobs::BaseJob
|
||||
backoff = 1.days
|
||||
end
|
||||
end
|
||||
ensure
|
||||
logger.trace("RefreshChannelsJob: #{id} fiber : Done")
|
||||
active_channel.send(true)
|
||||
end
|
||||
|
||||
active_channel.send(true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
logger.debug("RefreshChannelsJob: Done, sleeping for one minute")
|
||||
sleep 1.minute
|
||||
Fiber.yield
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user