def wait_start(self): """Start the process and wait for it to respond on HTTP.""" for _ in xrange(0, self.START_RETRIES): self.port = environment.get_port(self.port_name) if environment.get_protocol() == "grpc": self.grpc_port = environment.get_port(self.port_name, protocol="grpc") else: self.grpc_port = None logs_subdirectory = environment.get_logs_directory(self.directory) cmd = [self.binary, "-port", "%u" % self.port, "-log_dir", logs_subdirectory] if environment.get_protocol() == "grpc": cmd.extend(["-grpc_port", "%u" % self.grpc_port]) cmd.extend(self.extraparams) logging.info("Starting process: %s", cmd) stdout = os.path.join(logs_subdirectory, "%s.%d.log" % (self.name, self.port)) self.stdout = open(stdout, "w") self.process = subprocess.Popen(cmd, stdout=self.stdout, stderr=subprocess.STDOUT) timeout = time.time() + 60.0 while time.time() < timeout: if environment.process_is_healthy(self.name, self.addr()) and self.get_vars(): logging.info("%s started.", self.name) return elif self.process.poll() is not None: logging.error("%s process exited prematurely.", self.name) break time.sleep(0.3) logging.error("cannot start %s process on time: %s ", self.name, socket.getfqdn()) self.kill() raise Exception("Failed %d times to run %s" % (self.START_RETRIES, self.name))
def wait_start(self): """Start the process and wait for it to respond on HTTP.""" for _ in xrange(0, self.START_RETRIES): self.port = environment.get_port(self.port_name, instance=self.port_instance) if environment.get_protocol() == 'grpc': self.grpc_port = environment.get_port( self.port_name, instance=self.port_instance, protocol='grpc') else: self.grpc_port = None logs_subdirectory = environment.get_logs_directory(self.directory) cmd = [ self.binary, '-port', '%u' % self.port, '-log_dir', logs_subdirectory, ] if environment.get_protocol() == 'grpc': cmd.extend(['-grpc_port', '%u' % self.grpc_port]) cmd.extend(self.extraparams) logging.info('Starting process: %s', cmd) stdout = os.path.join(logs_subdirectory, '%s.%d.log' % (self.name, self.port)) self.stdout = open(stdout, 'w') self.process = subprocess.Popen(cmd, stdout=self.stdout, stderr=subprocess.STDOUT) timeout = time.time() + 60.0 while time.time() < timeout: if environment.process_is_healthy( self.name, self.addr()) and self.get_vars(): logging.info('%s started.', self.name) return elif self.process.poll() is not None: logging.error('%s process exited prematurely.', self.name) break time.sleep(0.3) logging.error('cannot start %s process on time: %s ', self.name, socket.getfqdn()) self.kill() raise Exception('Failed %d times to run %s' % (self.START_RETRIES, self.name))
def wait_start(self): """Start the process and wait for it to respond on HTTP.""" for _ in xrange(0, self.START_RETRIES): self.port = environment.get_port(self.port_name, instance=self.port_instance) logs_subdirectory = environment.get_logs_directory(self.directory) cmd = [ self.binary, '-port', '%u' % self.port, '-log_dir', logs_subdirectory, ] cmd.extend(self.extraparams) logging.info('Starting process: %s', cmd) stdout = os.path.join(logs_subdirectory, '%s.%d.log' % (self.name, self.port)) self.stdout = open(stdout, 'w') self.process = subprocess.Popen(cmd, stdout=self.stdout, stderr=subprocess.STDOUT) timeout = time.time() + 20.0 while time.time() < timeout: if environment.process_is_healthy(self.name, self.addr()) and self.get_vars(): logging.info('%s started.', self.name) return elif self.process.poll() is not None: logging.error('%s process exited prematurely.', self.name) break time.sleep(0.3) logging.error('cannot start %s process on time: %s ', self.name, socket.getfqdn()) self.kill() raise Exception('Failed %d times to run %s' % ( self.START_RETRIES, self.name))