forked from Fijxu/invidious
SigHelper: Reconnect to signature helper
This commit is contained in:
parent
b3e6aaddab
commit
d5b8b0b19c
1 changed files with 21 additions and 3 deletions
|
@ -176,7 +176,9 @@ module Invidious::SigHelper
|
||||||
|
|
||||||
@conn : Connection
|
@conn : Connection
|
||||||
|
|
||||||
def initialize(uri_or_path)
|
@uri_or_path : String
|
||||||
|
|
||||||
|
def initialize(@uri_or_path)
|
||||||
@conn = Connection.new(uri_or_path)
|
@conn = Connection.new(uri_or_path)
|
||||||
listen
|
listen
|
||||||
end
|
end
|
||||||
|
@ -186,10 +188,26 @@ module Invidious::SigHelper
|
||||||
|
|
||||||
LOGGER.debug("SigHelper: Multiplexor listening")
|
LOGGER.debug("SigHelper: Multiplexor listening")
|
||||||
|
|
||||||
# TODO: reopen socket if unexpectedly closed
|
|
||||||
spawn do
|
spawn do
|
||||||
loop 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
|
Fiber.yield
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue