def on_start(self): super(WebServiceInterface, self).on_start() setup_logger("werkzeug") setup_logger("gevent") if self.uses_static_port: try: socket_fd = self.container.get_shared_socket_fd(self.http_port) except NoSharedSockets: pass except SocketNotCreated: logger.warning( "socket for port %s wasn't created by node, binding from instance instead", self.http_port ) else: self.http_socket = sockets.create_socket("fd://%s" % socket_fd) if not self.http_socket: address = "%s:%s" % (self.container.server.ip, self.http_port) self.http_socket = sockets.create_socket(address) self.wsgi_server = LymphWSGIServer(self.http_socket, self.application, spawn=Group(self.pool_size)) self.wsgi_server.start() web_instance = ServiceInstance( id=self.id, identity=self.container.identity, hostname=socket.gethostname(), ip=self.container.server.ip, http_port=self.http_port, ) self.container.service_registry.register(self.name, web_instance, namespace="http")
def on_start(self): super(WebServiceInterface, self).on_start() setup_logger('werkzeug') setup_logger('gevent') if self.uses_static_port: try: socket_fd = self.container.get_shared_socket_fd(self.http_port) except NoSharedSockets: pass except SocketNotCreated: logger.warning( "socket for port %s wasn't created by node, binding from instance instead", self.http_port) else: self.http_socket = sockets.create_socket('fd://%s' % socket_fd) if not self.http_socket: address = '%s:%s' % (self.container.server.ip, self.http_port) self.http_socket = sockets.create_socket(address) self.wsgi_server = LymphWSGIServer(self.http_socket, self.application, spawn=Group(self.pool_size)) self.wsgi_server.start() web_instance = ServiceInstance( identity=self.container.identity, hostname=socket.gethostname(), ip=self.container.server.ip, http_port=self.http_port, ) self.container.service_registry.register(self.name, web_instance, namespace='http')
def on_start(self): super(WebServiceInterface, self).on_start() try: socket_fd = self.container.get_shared_socket_fd(self.http_port) except SocketNotCreated: socket = create_socket('%s:%s' % (self.config.get('ip') or self.container.ip, self.http_port), inheritable=True) socket_fd = socket.fileno() self.http_socket = create_socket('fd://%s' % socket_fd) self.wsgi_server = WSGIServer(self.http_socket, self.application, log=_LoggerStream()) self.wsgi_server.start()
def on_start(self): super(WebServiceInterface, self).on_start() setup_logger('werkzeug') setup_logger('gevent') try: socket_fd = self.container.get_shared_socket_fd(self.http_port) except SocketNotCreated: logger.warning("socket for port %s wasn't created by node, binding from instance instead", self.http_port) address = '%s:%s' % (self.container.server.ip, self.http_port) self.http_socket = create_socket(address) else: self.http_socket = create_socket('fd://%s' % socket_fd) self.wsgi_server = LymphWSGIServer(self.http_socket, self.application, spawn=Group(self.pool_size)) self.wsgi_server.start()
def on_start(self): super(WebServiceInterface, self).on_start() setup_logger('werkzeug') setup_logger('gevent') try: socket_fd = self.container.get_shared_socket_fd(self.http_port) except SocketNotCreated: logger.warning("socket for port %s wasn't created by node, binding from instance instead", self.http_port) address = '%s:%s' % (self.container.server.ip, self.http_port) self.http_socket = sockets.create_socket(address) else: self.http_socket = sockets.create_socket('fd://%s' % socket_fd) self.wsgi_server = LymphWSGIServer(self.http_socket, self.application, spawn=Group(self.pool_size)) self.wsgi_server.start()
def on_start(self): super(WebServiceInterface, self).on_start() try: socket_fd = self.container.get_shared_socket_fd(self.http_port) except SocketNotCreated: socket = create_socket( '%s:%s' % (self.config.get('ip') or self.container.ip, self.http_port), inheritable=True) socket_fd = socket.fileno() self.http_socket = create_socket('fd://%s' % socket_fd) self.wsgi_server = WSGIServer( self.http_socket, Request.application(self.dispatch_request)) self.wsgi_server.start()
def get_shared_socket_fd(self, port): try: return self.__shared_sockets[port].fileno() except KeyError: host_port = get_unused_port() sock = create_socket('127.0.0.1:%s' % host_port, inheritable=True) self.__shared_sockets[port] = sock return sock.fileno()
def setUp(self): # XXX(Mouad): Gevent master fail n python3 with: name 'dup' is not defined. # A workaround is to mock lymph.utils.sockets.create_socket to return # a dummy socket for us. port = get_unused_port() sock = create_socket('127.0.0.1:%s' % port, inheritable=True) with mock.patch('lymph.utils.sockets.create_socket', return_value=sock): super(WebServiceTestCase, self).setUp()
def create_shared_sockets(self): for host, port in self._sockets: sock = create_socket( '%s:%s' % (host or self.container.server.ip, port), inheritable=True) self.sockets[port] = sock