Example #1
0
def _start(process, node_name):
    log = logging.getLogger(__name__)
    startup_event = threading.Event()
    watcher = StartupWatcher(node_name, process, startup_event)
    t = threading.Thread(target=watcher.watch)
    t.setDaemon(True)
    t.start()
    if startup_event.wait(timeout=InProcessLauncher.PROCESS_WAIT_TIMEOUT_SECONDS):
        process.poll()
        # has the process terminated?
        if process.returncode:
            msg = "Node [%s] has terminated with exit code [%s]." % (node_name, str(process.returncode))
            log.error(msg)
            raise exceptions.LaunchError(msg)
        else:
            log.info("Started node [%s] with PID [%s].", node_name, process.pid)
            return process
    else:
        msg = "Could not start node [%s] within timeout period of [%s] seconds." % (
            node_name, InProcessLauncher.PROCESS_WAIT_TIMEOUT_SECONDS)
        # check if the process has terminated already
        process.poll()
        if process.returncode:
            msg += " The process has already terminated with exit code [%s]." % str(process.returncode)
        else:
            msg += " The process seems to be still running with PID [%s]." % process.pid
        log.error(msg)
        raise exceptions.LaunchError(msg)
Example #2
0
 def _start_process(self, env, node_name, binary_path):
     if os.geteuid() == 0:
         raise exceptions.LaunchError("Cannot launch Elasticsearch as root. Please run Rally as a non-root user.")
     os.chdir(binary_path)
     startup_event = threading.Event()
     cmd = ["bin/elasticsearch"]
     process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, stdin=subprocess.DEVNULL, env=env)
     t = threading.Thread(target=self._read_output, args=(node_name, process, startup_event))
     t.setDaemon(True)
     t.start()
     if startup_event.wait(timeout=InProcessLauncher.PROCESS_WAIT_TIMEOUT_SECONDS):
         process.poll()
         # has the process terminated?
         if process.returncode:
             msg = "Node [%s] has terminated with exit code [%s]." % (node_name, str(process.returncode))
             self.logger.error(msg)
             raise exceptions.LaunchError(msg)
         else:
             self.logger.info("Started node [%s] with PID [%s]", node_name, process.pid)
             return process
     else:
         msg = "Could not start node [%s] within timeout period of [%s] seconds." % (
             node_name, InProcessLauncher.PROCESS_WAIT_TIMEOUT_SECONDS)
         # check if the process has terminated already
         process.poll()
         if process.returncode:
             msg += " The process has already terminated with exit code [%s]." % str(process.returncode)
         else:
             msg += " The process seems to be still running with PID [%s]." % process.pid
         self.logger.error(msg)
         raise exceptions.LaunchError(msg)
Example #3
0
 def _start_process(self, env, node_name, binary_path):
     if os.geteuid() == 0:
         raise exceptions.LaunchError("Cannot launch Elasticsearch as root. Please run Rally as a non-root user.")
     os.chdir(binary_path)
     startup_event = threading.Event()
     cmd = ["bin/elasticsearch"]
     process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, stdin=subprocess.DEVNULL, env=env)
     t = threading.Thread(target=self._read_output, args=(node_name, process, startup_event))
     t.setDaemon(True)
     t.start()
     if startup_event.wait(timeout=InProcessLauncher.PROCESS_WAIT_TIMEOUT_SECONDS):
         process.poll()
         # has the process terminated?
         if process.returncode:
             msg = "Node [%s] has terminated with exit code [%s]." % (node_name, str(process.returncode))
             logger.error(msg)
             raise exceptions.LaunchError(msg)
         else:
             logger.info("Started node [%s] with PID [%s]" % (node_name, process.pid))
             return process
     else:
         msg = "Could not start node [%s] within timeout period of [%s] seconds." % (
             node_name, InProcessLauncher.PROCESS_WAIT_TIMEOUT_SECONDS)
         # check if the process has terminated already
         process.poll()
         if process.returncode:
             msg += " The process has already terminated with exit code [%s]." % str(process.returncode)
         else:
             msg += " The process seems to be still running with PID [%s]." % process.pid
         logger.error(msg)
         raise exceptions.LaunchError(msg)