Exemplo n.º 1
0
    def get_listen_addr(self):
        ip = None

        # if fiber.current_process() is multiprocessing.current_process():
        if not isinstance(fiber.current_process(), fiber.Process):
            # not inside docker
            # logger.debug("use interface docker0")
            ifce = "eth0"
            ip = find_ip_by_net_interface(ifce)
        else:
            # inside a Fiber process
            # logger.debug("use interface eth0")
            # ip = find_ip_by_net_interface("eth0")
            ip, ifce = find_listen_address()

        # ip = find_ip_by_net_interface(ifce)
        if ip is None:
            raise mp.ProcessError(
                "Can't find a usable IPv4 address to listen. ifce_name: {}, "
                "ifces: {}".format(ifce, psutil.net_if_addrs()))
        # use 0 to bind to a random free port number
        return ip, 0, ifce
Exemplo n.º 2
0
    def get_listen_addr(self):
        ip = None

        if sys.platform == "darwin":
            # use the same hostname for both master and non master process
            # because docker.for.mac.localhost resolves to different inside
            # and outside docker container. "docker.for.mac.localhost" is
            # the name that doesn't change in and outside the container.
            return "docker.for.mac.localhost", 0

        if not isinstance(fiber.current_process(), fiber.Process):
            # not inside docker
            ifce = "docker0"
            ip = find_ip_by_net_interface(ifce)
        else:
            # inside a Fiber process
            ip, ifce = find_listen_address()

        if ip is None:
            raise mp.ProcessError(
                "Can't find a usable IPv4 address to listen. ifce_name: {}, "
                "ifces: {}".format(ifce, psutil.net_if_addrs()))
        # use 0 to bind to a random free port number
        return ip, 0, ifce