1
0
Fork 0
mirror of https://github.com/morpheus65535/bazarr synced 2024-12-22 15:54:26 +00:00

Fixed restart loop when TCP port already in use.

This commit is contained in:
morpheus65535 2024-04-06 10:03:09 -04:00
parent ad16acb88f
commit 3e9cfea3c5
2 changed files with 12 additions and 4 deletions

View file

@ -4,7 +4,7 @@ import signal
import warnings import warnings
import logging import logging
import errno import errno
from literals import EXIT_INTERRUPT, EXIT_NORMAL from literals import EXIT_INTERRUPT, EXIT_NORMAL, EXIT_PORT_ALREADY_IN_USE_ERROR
from utilities.central import restart_bazarr, stop_bazarr from utilities.central import restart_bazarr, stop_bazarr
from waitress.server import create_server from waitress.server import create_server
@ -56,10 +56,17 @@ class Server:
logging.exception("BAZARR cannot bind to specified IP, trying with default (0.0.0.0)") logging.exception("BAZARR cannot bind to specified IP, trying with default (0.0.0.0)")
self.address = '0.0.0.0' self.address = '0.0.0.0'
self.connected = False self.connected = False
super(Server, self).__init__()
elif error.errno == errno.EADDRINUSE: elif error.errno == errno.EADDRINUSE:
if self.port != '6767':
logging.exception("BAZARR cannot bind to specified TCP port, trying with default (6767)") logging.exception("BAZARR cannot bind to specified TCP port, trying with default (6767)")
self.port = '6767' self.port = '6767'
self.connected = False self.connected = False
super(Server, self).__init__()
else:
logging.exception("BAZARR cannot bind to default TCP port (6767) because it's already in use, "
"exiting...")
self.shutdown(EXIT_PORT_ALREADY_IN_USE_ERROR)
else: else:
logging.exception("BAZARR cannot start because of unhandled exception.") logging.exception("BAZARR cannot start because of unhandled exception.")
self.shutdown() self.shutdown()

View file

@ -28,3 +28,4 @@ EXIT_VALIDATION_ERROR = -101
EXIT_CONFIG_CREATE_ERROR = -102 EXIT_CONFIG_CREATE_ERROR = -102
EXIT_PYTHON_UPGRADE_NEEDED = -103 EXIT_PYTHON_UPGRADE_NEEDED = -103
EXIT_REQUIREMENTS_ERROR = -104 EXIT_REQUIREMENTS_ERROR = -104
EXIT_PORT_ALREADY_IN_USE_ERROR = -105