summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamantaz Fox <coding@samantaz.fr>2024-10-30 17:02:51 +0100
committerSamantaz Fox <coding@samantaz.fr>2024-10-30 17:02:51 +0100
commit2eeb6a731dcf0beb30ea1a14e3db4478c1b7055f (patch)
treed799de6c8afb051ddbee07aa6641c60f271b1f3a
parent0fb67cc090f10c3353812cf99be1ad97ccc1bbe4 (diff)
parent84e4746265d6077b1537b626c9742498f9cb253c (diff)
downloadinvidious-2eeb6a731dcf0beb30ea1a14e3db4478c1b7055f.tar.gz
invidious-2eeb6a731dcf0beb30ea1a14e3db4478c1b7055f.tar.bz2
invidious-2eeb6a731dcf0beb30ea1a14e3db4478c1b7055f.zip
SigHelper: Reconnect to signature helper (#4991)
Fijxu have been using it for more than 3 weeks on their instance and they report that it works really well. This only works if 'inv_sig_helper' itself crashes and restarts (via systemd or docker restart policy) but it will not work if 'inv_sig_helper' hangs and stops responding to invidious (but this is an issue with 'inv_sig_helper', not Invidious). Closes issue 4926
-rw-r--r--src/invidious/helpers/sig_helper.cr23
1 files changed, 20 insertions, 3 deletions
diff --git a/src/invidious/helpers/sig_helper.cr b/src/invidious/helpers/sig_helper.cr
index 9e72c1c7..6d198a42 100644
--- a/src/invidious/helpers/sig_helper.cr
+++ b/src/invidious/helpers/sig_helper.cr
@@ -175,8 +175,9 @@ module Invidious::SigHelper
@queue = {} of TransactionID => Transaction
@conn : Connection
+ @uri_or_path : String
- def initialize(uri_or_path)
+ def initialize(@uri_or_path)
@conn = Connection.new(uri_or_path)
listen
end
@@ -186,10 +187,26 @@ module Invidious::SigHelper
LOGGER.debug("SigHelper: Multiplexor listening")
- # TODO: reopen socket if unexpectedly closed
spawn do
loop do
- receive_data
+ begin
+ receive_data
+ rescue ex
+ LOGGER.info("SigHelper: Connection to helper died with '#{ex.message}' trying to reconnect...")
+ # We close the socket because for some reason is not closed.
+ @conn.close
+ loop do
+ begin
+ @conn = Connection.new(@uri_or_path)
+ LOGGER.info("SigHelper: Reconnected to SigHelper!")
+ rescue ex
+ LOGGER.debug("SigHelper: Reconnection to helper unsuccessful with error '#{ex.message}'. Retrying")
+ sleep 500.milliseconds
+ next
+ end
+ break if !@conn.closed?
+ end
+ end
Fiber.yield
end
end