diff options
| author | Fijxu <fijxu@nadeko.net> | 2024-09-18 18:14:28 -0300 |
|---|---|---|
| committer | Fijxu <fijxu@nadeko.net> | 2024-10-08 19:09:14 -0300 |
| commit | 84e4746265d6077b1537b626c9742498f9cb253c (patch) | |
| tree | 1e3b8748be6b5204909e8adfbbb5317b45960263 | |
| parent | a88a723de3a3d96d8ff748cb117ae48265ee552c (diff) | |
| download | invidious-84e4746265d6077b1537b626c9742498f9cb253c.tar.gz invidious-84e4746265d6077b1537b626c9742498f9cb253c.tar.bz2 invidious-84e4746265d6077b1537b626c9742498f9cb253c.zip | |
SigHelper: Reconnect to signature helper
Signed-off-by: Fijxu <fijxu@nadeko.net>
| -rw-r--r-- | src/invidious/helpers/sig_helper.cr | 23 |
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 |
