morpheus65535 / bazarr

Bazarr is a companion application to Sonarr and Radarr. It manages and downloads subtitles based on your requirements. You define your preferences by TV show or movie and Bazarr takes care of everything for you.
https://www.bazarr.media
GNU General Public License v3.0
2.78k stars 218 forks source link

Doesn't launch if there's no internet access #2467

Closed gudvinr closed 4 months ago

gudvinr commented 4 months ago

Describe the bug

If there's no internet access, bazarr instance fails to launch and ends up in inaccessible state.

To Reproduce Steps to reproduce the behavior:

  1. Emulate missing interned (e.g. by blocking outbound traffic from bazarr via firewall)

Expected behavior Bazarr starts. Although it won't be able to fetch subtitles, at least it won't spam logs with errors and won't restart endlessly.

Screenshots If applicable, add screenshots to help explain your problem.

Software (please complete the following information):

Additional context

bazarr-1  | 2024-04-24 20:34:16,506 - root                             (7fd39f410b80) :  ERROR (announcements:51) - Error trying to get announcements from Github. Connection Error.
bazarr-1  | 2024-04-24 20:36:27,312 - root                             (7fd39f410b80) :  ERROR (binaries:94) - BAZARR unable to download unrar to /opt/bazarr/bin/Linux/x86_64/unrar
bazarr-1  | 2024-04-24 20:36:27,316 - root                             (7fd39f410b80) :  ERROR (init:216) - BAZARR requires a rar archive extraction utilities (unrar, unar, 7zip) and it can't be found.
bazarr-1  | Traceback (most recent call last):
bazarr-1  |   File "/opt/bazarr/bazarr/init.py", line 196, in init_binaries
bazarr-1  |     exe = get_binary("unar")
bazarr-1  |   File "/opt/bazarr/bazarr/utilities/binaries.py", line 73, in get_binary
bazarr-1  |     raise BinaryNotFound
bazarr-1  | utilities.binaries.BinaryNotFound
bazarr-1  | 
bazarr-1  | During handling of the above exception, another exception occurred:
bazarr-1  | 
bazarr-1  | Traceback (most recent call last):
bazarr-1  |   File "/opt/bazarr/bazarr/../libs/urllib3/connection.py", line 174, in _new_conn
bazarr-1  |     conn = connection.create_connection(
bazarr-1  |   File "/opt/bazarr/bazarr/../libs/subliminal_patch/http.py", line 325, in patched_create_connection
bazarr-1  |     return _orig_create_connection(address, *args, **kwargs)
bazarr-1  |   File "/opt/bazarr/bazarr/../libs/urllib3/util/connection.py", line 95, in create_connection
bazarr-1  |     raise err
bazarr-1  |   File "/opt/bazarr/bazarr/../libs/urllib3/util/connection.py", line 85, in create_connection
bazarr-1  |     sock.connect(sa)
bazarr-1  | TimeoutError: [Errno 110] Connection timed out
bazarr-1  | 
bazarr-1  | During handling of the above exception, another exception occurred:
bazarr-1  | 
bazarr-1  | Traceback (most recent call last):
bazarr-1  |   File "/opt/bazarr/bazarr/../libs/urllib3/connectionpool.py", line 703, in urlopen
bazarr-1  |     httplib_response = self._make_request(
bazarr-1  |   File "/opt/bazarr/bazarr/../libs/urllib3/connectionpool.py", line 386, in _make_request
bazarr-1  |     self._validate_conn(conn)
bazarr-1  |   File "/opt/bazarr/bazarr/../libs/urllib3/connectionpool.py", line 1042, in _validate_conn
bazarr-1  |     conn.connect()
bazarr-1  |   File "/opt/bazarr/bazarr/../libs/urllib3/connection.py", line 358, in connect
bazarr-1  |     self.sock = conn = self._new_conn()
bazarr-1  |   File "/opt/bazarr/bazarr/../libs/urllib3/connection.py", line 179, in _new_conn
bazarr-1  |     raise ConnectTimeoutError(
bazarr-1  | urllib3.exceptions.ConnectTimeoutError: (<urllib3.connection.HTTPSConnection object at 0x7fd39391e980>, 'Connection to github.com timed out. (connect timeout=None)')
bazarr-1  | 
bazarr-1  | During handling of the above exception, another exception occurred:
bazarr-1  | 
bazarr-1  | Traceback (most recent call last):
bazarr-1  |   File "/opt/bazarr/bazarr/../libs/requests/adapters.py", line 489, in send
bazarr-1  |     resp = conn.urlopen(
bazarr-1  |   File "/opt/bazarr/bazarr/../libs/urllib3/connectionpool.py", line 787, in urlopen
bazarr-1  |     retries = retries.increment(
bazarr-1  |   File "/opt/bazarr/bazarr/../libs/urllib3/util/retry.py", line 592, in increment
bazarr-1  |     raise MaxRetryError(_pool, url, error or ResponseError(cause))
bazarr-1  | urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='github.com', port=443): Max retries exceeded with url: /morpheus65535/bazarr-binaries/raw/master/bin/Linux/x86_64/unrar/unrar (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x7fd39391e980>, 'Connection to github.com timed out. (connect timeout=None)'))
bazarr-1  | 
bazarr-1  | During handling of the above exception, another exception occurred:
bazarr-1  | 
bazarr-1  | Traceback (most recent call last):
bazarr-1  |   File "/opt/bazarr/bazarr/utilities/binaries.py", line 85, in get_binary
bazarr-1  |     r = requests.get(binary['url'])
bazarr-1  |   File "/opt/bazarr/bazarr/../libs/requests/api.py", line 73, in get
bazarr-1  |     return request("get", url, params=params, **kwargs)
bazarr-1  |   File "/opt/bazarr/bazarr/../libs/requests/api.py", line 59, in request
bazarr-1  |     return session.request(method=method, url=url, **kwargs)
bazarr-1  |   File "/opt/bazarr/bazarr/../libs/requests/sessions.py", line 587, in request
bazarr-1  |     resp = self.send(prep, **send_kwargs)
bazarr-1  |   File "/opt/bazarr/bazarr/../libs/requests/sessions.py", line 701, in send
bazarr-1  |     r = adapter.send(request, **kwargs)
bazarr-1  |   File "/opt/bazarr/bazarr/../libs/requests/adapters.py", line 553, in send
bazarr-1  |     raise ConnectTimeout(e, request=request)
bazarr-1  | requests.exceptions.ConnectTimeout: HTTPSConnectionPool(host='github.com', port=443): Max retries exceeded with url: /morpheus65535/bazarr-binaries/raw/master/bin/Linux/x86_64/unrar/unrar (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x7fd39391e980>, 'Connection to github.com timed out. (connect timeout=None)'))
bazarr-1  | 
bazarr-1  | During handling of the above exception, another exception occurred:
bazarr-1  | 
bazarr-1  | Traceback (most recent call last):
bazarr-1  |   File "/opt/bazarr/bazarr/init.py", line 203, in init_binaries
bazarr-1  |     exe = get_binary("unrar")
bazarr-1  |   File "/opt/bazarr/bazarr/utilities/binaries.py", line 95, in get_binary
bazarr-1  |     raise BinaryNotFound
bazarr-1  | utilities.binaries.BinaryNotFound
bazarr-1  | 
bazarr-1  | During handling of the above exception, another exception occurred:
bazarr-1  | 
bazarr-1  | Traceback (most recent call last):
bazarr-1  |   File "/opt/bazarr/bazarr/init.py", line 210, in init_binaries
bazarr-1  |     exe = get_binary("7z")
bazarr-1  |   File "/opt/bazarr/bazarr/utilities/binaries.py", line 73, in get_binary
bazarr-1  |     raise BinaryNotFound
bazarr-1  | utilities.binaries.BinaryNotFound
bazarr-1  | 
bazarr-1  | During handling of the above exception, another exception occurred:
bazarr-1  | 
bazarr-1  | Traceback (most recent call last):
bazarr-1  |   File "/opt/bazarr/bazarr/main.py", line 22, in <module>
bazarr-1  |     from init import *  # noqa E402
bazarr-1  |   File "/opt/bazarr/bazarr/init.py", line 230, in <module>
bazarr-1  |     init_binaries()
bazarr-1  |   File "/opt/bazarr/bazarr/init.py", line 217, in init_binaries
bazarr-1  |     raise BinaryNotFound
bazarr-1  | utilities.binaries.BinaryNotFound
bazarr-1  | Bazarr starting...
bazarr-1  | Bazarr exited.
morpheus65535 commented 4 months ago

I don't understand the issue here. Bazarr require the RAR archive utility to work. It simply raise an exception and we send the exception stack to log. There's no spam in this.

gudvinr commented 4 months ago

It raises exception, exits, tries to start again, again raises exception, etc

Strictly specking, bazarr itself doesn't even need unrar to launch.
From source code I see that only few providers use unrar. None of which are enabled in my installation.

morpheus65535 commented 4 months ago

It raises exception, exits, tries to start again, again raises exception, etc

I'm unable to reproduce this behaviour. It raise exception and exit. How do you run Bazarr?

Strictly specking, bazarr itself doesn't even need unrar to launch. From source code I see that only few providers use unrar. None of which are enabled in my installation.

Although it's not strictly required if you don't enable specific providers, we took a design decision to make it mandatory to simplify code base. We have no plan to change that decision.

gudvinr commented 4 months ago

I'm unable to reproduce this behaviour. It raise exception and exit. How do you run Bazarr?

Yes, it does just exit. But it would be safe to say that virtually nobody runs daemons by hand as one-shot application.
People would use some kind of management tool. Docker, systemd, upstart, etc, windows service, plain autostart .desktop files, etc

I use docker, thus container gets restarted because of application exiting.
And that would be the same for basically any other management tool.

Although it's not strictly required if you don't enable specific providers, we took a design decision to make it mandatory to simplify code base. We have no plan to change that decision.

It still shouldn't stop from launching self-hosted (!) service because URL to download said tool is unavailable. Simply because it can be retried until success, executed in background and have some sort of resiliency against network errors.

Or, if unrar is not available on the system and can't be downloaded, exception can be thrown when unrar is used instead. And download can be logged as a warning and not cause hard failure.

morpheus65535 commented 4 months ago

You would prefer if it just hang their instead of existing when exception is raised? Your docker image provider should already have included the required a supported unrar tools. If not, it's definitely not one of our supported images providers (LSIO or Hotio).

I don't want to have to deal with missing unrar tools later in multiple places. I've decided that it's mandatory so if it's not installed, Bazarr will just wont start. If it's already installed or if it's available in the Bazarr bin directory, Bazarr will start even if there's no internet connection. Again, it's a non-issue once you've installed the requirement.

morpheus65535 commented 4 months ago

If there's something else to discuss here, let me know.