def init_servers(self): """Initialize the HTTP server""" try: # Import modules here to intercept possible missing libraries on linux systems from resources.lib.services.http_server import NFThreadedTCPServer self.nf_server_instance = NFThreadedTCPServer( (self.HOST_ADDRESS, select_port('NF_SERVER'))) self.nf_server_instance.allow_reuse_address = True self.nf_server_thread = threading.Thread( target=self.nf_server_instance.serve_forever) return True except Exception as exc: # pylint: disable=broad-except LOG.error( 'Background services do not start due to the following error') import traceback LOG.error(traceback.format_exc()) if isinstance(exc, gaierror): message = ( 'Something is wrong in your network localhost configuration.\r\n' f'It is possible that the hostname {self.HOST_ADDRESS} can not be resolved.' ) elif isinstance(exc, ImportError): message = ( 'In your system is missing some required library to run Netflix.\r\n' 'Read how to install the add-on in the GitHub Readme.\r\n' f'Error details: {exc}') else: message = str(exc) self._set_service_status('error', message) return False
def init_server(self, server): server['class'].allow_reuse_address = True server['instance'] = server['class']( ('127.0.0.1', select_port(server['name']))) server['thread'] = threading.Thread( target=server['instance'].serve_forever)
def _init_server(self, server): server['class'].allow_reuse_address = True server['instance'] = server['class']( (self.HOST_ADDRESS, select_port(server['name']))) server['thread'] = threading.Thread( target=server['instance'].serve_forever)