当前位置: 首页>>代码示例>>Python>>正文


Python nuclide_server.NuclideServer类代码示例

本文整理汇总了Python中nuclide_server.NuclideServer的典型用法代码示例。如果您正苦于以下问题:Python NuclideServer类的具体用法?Python NuclideServer怎么用?Python NuclideServer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了NuclideServer类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: start_nuclide

    def start_nuclide(self):
        if self.options.port is None:
            port = self._obtain_nuclide_server_port()
            if port is None:
                return 1
        else:
            port = self.options.port

        server = NuclideServer(port, self.options.workspace)

        # If given port is being used by somebody else, you shall not pass.
        if not self._is_port_open(port) and not server.is_mine():
            print('You are not the owner of Nuclide server at port %d. Try a different port.' %
                port, file=sys.stderr)
            return 1

        # At this moment, the port is either open, or we have an existing server running.
        if server.is_running():
            version = NuclideServerManager._get_version()
            running_version = server.get_version()
            # If the common names don't match, we restart.
            if (version and version != running_version) or \
                (self.options.common_name and server.get_common_name() != self.options.common_name):
                print('Restarting Nuclide server on port %d' % port, file=sys.stderr)
                server.stop()
                return self.start_server(server)
                # Don't use restart() here, so that we regenerate the certificates.
            else:
                print('Nuclide already running on port %d. You may connect.' % port, file=sys.stderr)
                server.print_json()
                return 0
        else:
            return self.start_server(server)
开发者ID:huamichaelchen,项目名称:nuclide,代码行数:33,代码来源:nuclide_server_manager.py

示例2: cleanup

    def cleanup(self):
        self.logger.info('Starting to clean up old Nuclide processes/files.')
        # TODO: Remove it after migration is complete.
        # For migration, stop the forever monitor processes of Nuclide server.
        # This does not stop existing Nuclide server processes themselves.
        # It just removes the monitor so that we can kill them on upgrade.
        for proc in ProcessInfo.get_processes(
                getpass.getuser(), '%s.*%s' %
                (re.escape('forever/bin/monitor'), re.escape('nuclide-main.js'))):
            self.logger.info('Stopping forever monitor process: %s' % proc)
            proc.stop()

        # Clean up multiple Nuclide processes on same port.
        # There should be no more than one on a given port.
        # TODO: log the error to analytics db.
        # { port1 => [proc1, proc2, ...], ...}
        server_proc_map = defaultdict(list)
        # Group the processes by port.
        for proc in NuclideServer.get_processes():
            port = int(proc.get_command_param('port'))
            server_proc_map[port].append(proc)
        for port in server_proc_map:
            if len(server_proc_map[port]) > 1:
                self.logger.warning(
                    'Multiple Nuclide processes on port %d. Something wrong. Clean them up...' %
                    port)
                for proc in server_proc_map[port]:
                    proc.stop()

        self.cleanup_certificates(CERTS_EXPIRATION_DAYS)
        self.logger.info('Finished cleaning up old Nuclide processes/files.')
开发者ID:mahinko,项目名称:nuclide,代码行数:31,代码来源:nuclide_server_manager.py

示例3: cleanup

    def cleanup(self):

        # TODO: Remove it after migration is complete.
        # For migration, stop the forever monitor processes of Nuclide server.
        # This does not stop existing Nuclide server processes themselves.
        # It just removes the monitor so that we can kill them on upgrade.
        for proc in ProcessInfo.get_processes(
            getpass.getuser(), "%s.*%s" % (re.escape("forever/bin/monitor"), re.escape("nuclide-main.js"))
        ):
            print("Stopping %s" % proc, file=sys.stderr)
            proc.stop()

        # Clean up multiple Nuclide processes on same port.
        # There should be no more than one on a given port.
        # TODO: log the error to analytics db.
        # { port1 => [proc1, proc2, ...], ...}
        server_proc_map = defaultdict(list)
        # Group the processes by port.
        for proc in NuclideServer.get_processes():
            port = int(proc.get_command_param("port"))
            server_proc_map[port].append(proc)
        for port in server_proc_map:
            if len(server_proc_map[port]) > 1:
                print(
                    "Multiple Nuclide processes on port %d. Something wrong. Clean them up..." % port, file=sys.stderr
                )
                for proc in server_proc_map[port]:
                    proc.stop()

        self.cleanup_certificates(CERTS_EXPIRATION_DAYS)
开发者ID:etcinit,项目名称:nuclide,代码行数:30,代码来源:nuclide_server_manager.py

示例4: list_servers

 def list_servers(user=getpass.getuser(), port_filter=[]):
     servers = []
     for proc in NuclideServer.get_processes(user):
         port = int(proc.get_command_param('port'))
         if not port_filter or port in port_filter:
             server = NuclideServer(port, proc=proc)
             servers.append(server)
     return servers
开发者ID:mahinko,项目名称:nuclide,代码行数:8,代码来源:nuclide_server_manager.py

示例5: start_nuclide

    def start_nuclide(self):
        self.logger.info("Trying to determine the port to use for Nuclide server...")
        if self.options.port is None:
            port = self._obtain_nuclide_server_port()
            if port is None:
                print(
                    "Failed to start Nuclide server because there are no ports available. \
                       Here are the busy ports that were tried: {0}".format(
                        OPEN_PORTS
                    )
                )
                self.logger.error("Failed to start Nuclide server because there are no ports available.")
                return 1
        else:
            self.logger.error("The user specified port {0}.".format(self.options.port))
            port = self.options.port

        server = NuclideServer(port, self.options.workspace)
        self.logger.info("Initialized NuclideServer.")

        # If given port is being used by somebody else, you shall not pass.
        if not self._is_port_open(port) and not server.is_mine():
            print("You are not the owner of Nuclide server at port %d. Try a different port." % port, file=sys.stderr)
            self.logger.error("You are not the owner of Nuclide server at port %d. Try a different port." % port)
            return 1

        # At this moment, the port is either open, or we have an existing server running.
        if server.is_running():
            version = NuclideServerManager._get_version()
            running_version = server.get_version()
            self.logger.info(
                "A Nuclide server is already running. \
                              Running version: {0}. Desired version: {1}.".format(
                    running_version, version
                )
            )
            # If the common names don't match, we restart.
            if (version and version != running_version) or (
                self.options.common_name and server.get_common_name() != self.options.common_name
            ):
                self.logger.info("Restarting Nuclide server on port %d" % port)
                server.stop()
                return self.start_server(server)
                # Don't use restart() here, so that we regenerate the certificates.
            else:
                self.logger.info("Nuclide server already running on port %d. User may connect." % port)
                server.print_json()
                return 0
        else:
            return self.start_server(server)
开发者ID:rugby110,项目名称:nuclide,代码行数:50,代码来源:nuclide_server_manager.py

示例6: cleanup

    def cleanup(self):
        self.logger.info("Starting to clean up old Nuclide processes/files.")
        # Clean up multiple Nuclide processes on same port.
        # There should be no more than one on a given port.
        # TODO: log the error to analytics db.
        # { port1 => [proc1, proc2, ...], ...}
        server_proc_map = defaultdict(list)
        # Group the processes by port.
        for proc in NuclideServer.get_processes():
            port = int(proc.get_command_param("port"))
            server_proc_map[port].append(proc)
        for port in server_proc_map:
            if len(server_proc_map[port]) > 1:
                self.logger.warning("Multiple Nuclide processes on port %d. Something wrong. Clean them up..." % port)
                for proc in server_proc_map[port]:
                    proc.stop()

        self.cleanup_certificates(CERTS_EXPIRATION_DAYS)
        self.logger.info("Finished cleaning up old Nuclide processes/files.")
开发者ID:PKRoma,项目名称:nuclide,代码行数:19,代码来源:nuclide_server_manager.py

示例7: start_nuclide

    def start_nuclide(self):
        server = None
        self.logger.info('Trying to determine the port to use for Nuclide server...')
        if self.options.port is None:
            port = self._obtain_nuclide_server_port()
            if port is None:
                self.logger.error(
                    'Failed to start Nuclide server because there are no ports available.')
                return {'exit_code': 1, 'server': server}
        else:
            self.logger.error('The user specified port {0}.'.format(self.options.port))
            port = self.options.port

        server = NuclideServer(port, self.options.workspace)
        self.logger.info('Initialized NuclideServer.')

        # If given port is being used by somebody else, you shall not pass.
        if not self._is_port_open(port) and not server.is_mine():
            self.logger.error(
                'You are not the owner of Nuclide server at port %d. Try a different port.' %
                port)
            return {'exit_code': 1, 'server': server}

        # At this moment, the port is either open, or we have an existing server running.
        if not server.is_running():
            return {'exit_code': self.start_server(server), 'server': server}

        version = NuclideServerManager._get_version()
        running_version = server.get_version()
        self.logger.info(
            'A Nuclide server is already running. \
            Running version: {0}. Desired version: {1}.'.format(running_version, version)
        )
        # If the common names don't match, we restart.
        if (version and version != running_version) or (
                self.options.common_name and server.get_common_name() != self.options.common_name):
            self.logger.info('Restarting Nuclide server on port %d' % port)
            server.stop()
            # Don't use restart() here, so that we regenerate the certificates.
            return {'exit_code': self.start_server(server), 'server': server}
        else:
            self.logger.info(
                'Nuclide server already running on port %d. User may connect.' %
                port)
            return {'exit_code': 0, 'server': server}
开发者ID:JoelMarcey,项目名称:nuclide,代码行数:45,代码来源:nuclide_server_manager.py

示例8: test_get_certificates

 def test_get_certificates(self):
     gen = NuclideCertificatesGenerator(tempfile.gettempdir(), 'localhost', 'test')
     server_9090 = NuclideServer(9090)
     ret = server_9090.start(timeout=TIMEOUT, cert=gen.server_cert, key=gen.server_key, ca=gen.ca_cert)
     self.assertEquals(ret, 0)
     # Verify cert files.
     server_cert, server_key, ca = server_9090.get_server_certificate_files()
     self.assertEquals(server_cert, gen.server_cert)
     self.assertEquals(server_key, gen.server_key)
     self.assertEquals(ca, gen.ca_cert)
     client_cert, client_key = NuclideServer.get_client_certificate_files(ca)
     self.assertEquals(client_cert, gen.client_cert)
     self.assertEquals(client_key, gen.client_key)
     # Verify same cert files after restart.
     server_9090.restart(timeout=TIMEOUT)
     server_cert, server_key, ca = server_9090.get_server_certificate_files()
     self.assertEquals(server_cert, gen.server_cert)
     self.assertEquals(server_key, gen.server_key)
     self.assertEquals(ca, gen.ca_cert)
开发者ID:dalinaum,项目名称:nuclide,代码行数:19,代码来源:nuclide_server_test.py

示例9: test_multiple_servers

    def test_multiple_servers(self):
        server_9090 = NuclideServer(9090)
        self.assertEquals(server_9090.start(timeout=TIMEOUT), 0)
        self.assertTrue(server_9090.is_healthy())
        server_9091 = NuclideServer(9091)
        self.assertEquals(server_9091.start(timeout=TIMEOUT), 0)
        self.assertTrue(server_9091.is_healthy())
        # No server on port 9092
        server_9092 = NuclideServer(9092)
        self.assertFalse(server_9092.is_healthy())
        self.assertEquals(server_9090.stop(), 0)
        self.assertFalse(server_9090.is_healthy())
        self.assertTrue(server_9091.is_healthy())

        # Create new server objects to rebind and check states again.
        server_9090 = NuclideServer(9090)
        server_9091 = NuclideServer(9091)
        self.assertFalse(server_9090.is_healthy())
        self.assertTrue(server_9091.is_healthy())
开发者ID:BruceZu,项目名称:nuclide,代码行数:19,代码来源:nuclide_server_test.py


注:本文中的nuclide_server.NuclideServer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。