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)
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)
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)
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}
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)