class_docstr: Handle to an H2O server launched locally.
  
  Public interface::
  
      hs = H2OLocalServer.start(...)  # launch a new local H2O server
      hs.is_running()                 # check if the server is running
      hs.shutdown()                   # shut down the server
      hs.scheme                       # either "http" or "https"
      hs.ip                           # ip address of the server, typically "127.0.0.1"
      hs.port                         # port on which the server is listening
  
  Once started, the server will run until the script terminates, or until you call ``.shutdown()`` on it. Moreover,
  if the server terminates with an exception, then the server will not stop and will continue to run even after
  Python process exits. This runaway process may end up being in a bad shape (e.g. frozen), then the only way to
  terminate it is to end the Java process from the terminal.
  
  Alternatively, it is possible to start the server as a context manager, in which case it will be automatically
  shut down even if an exception occurs in Python (but not if the Python process is killed)::
  
      with H2OLocalServer.start() as hs:
          # do something with the server -- probably connect to it
class_docstr_tok: ["Handle","to","an","H2O","server","launched","locally",".","Public","interface",":",":","hs","=","H2OLocalServer.start","(","...",")","#","launch","a","new","local","H2O","server","hs.is_running","(",")","#","check","if","the","server","is","running","hs.shutdown","(",")","#","shut","down","the","server","hs.scheme","#","either","``","http","''","or","``","https","''","hs.ip","#","ip","address","of","the","server",",","typically","``","127.0.0.1","''","hs.port","#","port","on","which","the","server","is","listening","Once","started",",","the","server","will","run","until","the","script","terminates",",","or","until","you","call","``",".shutdown","(",")","``","on","it",".","Moreover",",","if","the","server","terminates","with","an","exception",",","then","the","server","will","not","stop","and","will","continue","to","run","even","after","Python","process","exits",".","This","runaway","process","may","end","up","being","in","a","bad","shape","(","e.g",".","frozen",")",",","then","the","only","way","to","terminate","it","is","to","end","the","Java","process","from","the","terminal",".","Alternatively",",","it","is","possible","to","start","the","server","as","a","context","manager",",","in","which","case","it","will","be","automatically","shut","down","even","if","an","exception","occurs","in","Python","(","but","not","if","the","Python","process","is","killed",")",":",":","with","H2OLocalServer.start","(",")","as","hs",":","#","do","something","with","the","server","--","probably","connect","to","it"]
docstr: Actually start the h2o.jar executable (helper method for `.start()`).
docstr_tok: ["Actually","start","the","h2o.jar","executable","(","helper","method","for","`",".start","(",")","`",")","."]
code: def _launch_server(
      self,
      port,
      baseport,
      mmax,
      mmin,
      ea,
      nthreads,
      jvm_custom_args,
      bind_to_localhost,
      log_dir=None,
      log_level=None,
      max_log_file_size=None,
  ):
      """Actually start the h2o.jar executable (helper method for `.start()`)."""
      self._ip = "127.0.0.1"
  
      # Find Java and check version. (Note that subprocess.check_output returns the output as a bytes object)
      java = self._find_java()
      self._check_java(java, self._verbose)
  
      if self._verbose:
          print("  Starting server from " + self._jar_path)
          print("  Ice root: " + self._ice_root)
  
      # Construct java command to launch the process
      cmd = [java]
  
      # ...add JVM options
      cmd += ["-ea"] if ea else []
      for mq, num in [("-Xms", mmin), ("-Xmx", mmax)]:
          if num is None:
              continue
          numstr = (
              "%dG" % (num >> 30)
              if num == (num >> 30) << 30
              else "%dM" % (num >> 20)
              if num == (num >> 20) << 20
              else str(num)
          )
          cmd += [mq + numstr]
      if jvm_custom_args is not None:
          for arg in jvm_custom_args:
              assert type(arg) is str
              cmd += [arg]
  
      # This should be the last JVM option
      if self._extra_classpath is None:
          # Use jar file directly
          cmd += ["-jar", self._jar_path]
      else:
          # Combine jar path with the optional extra classpath
          classpath = [self._jar_path] + self._extra_classpath
          cmd += ["-cp", os.pathsep.join(classpath), "water.H2OApp"]
  
      # ...add H2O options
      cmd += ["-ip", self._ip]
      if bind_to_localhost:
          cmd += ["-web_ip", self._ip]
      cmd += ["-port", str(port)] if port else []
      cmd += ["-baseport", str(baseport)] if baseport else []
      cmd += ["-ice_root", self._ice_root]
      cmd += ["-nthreads", str(nthreads)] if nthreads > 0 else []
  
      if log_dir:
          cmd += ["-log_dir", log_dir]
  
      if log_level:
          cmd += ["-log_level", log_level]
  
      if max_log_file_size:
          cmd += ["-max_log_file_size", max_log_file_size]
  
      if not self._name:
          self._name = "H2O_from_python_%s" % self._tmp_file("salt")
      cmd += ["-name", self._name]
  
      # Warning: do not change to any higher log-level, otherwise we won't be able to know which port the
      # server is listening to.
      cmd += ["-log_level", "INFO"]
      cmd += ["-allow_unsupported_java"]
  
      # Create stdout and stderr files
      self._stdout = self._tmp_file("stdout")
      self._stderr = self._tmp_file("stderr")
      cwd = os.path.abspath(os.getcwd())
      out = open(self._stdout, "w", encoding="utf-8")
      err = open(self._stderr, "w", encoding="utf-8")
      if self._verbose:
          print("  JVM stdout: " + out.name)
          print("  JVM stderr: " + err.name)
  
      # Launch the process
      win32 = sys.platform == "win32"
      flags = (
          getattr(subprocess, "CREATE_NEW_PROCESS_GROUP", 0)
          if win32
          else 0
      )
      prex = os.setsid if not win32 else None
      try:
          proc = subprocess.Popen(
              args=cmd,
              stdout=out,
              stderr=err,
              cwd=cwd,
              creationflags=flags,
              preexec_fn=prex,
          )
      except OSError as e:
          traceback = getattr(e, "child_traceback", None)
          raise H2OServerError(
              "Unable to start server: %s" % e, traceback
          )
  
      # Wait until the server is up-and-running
      giveup_time = time.time() + self._TIME_TO_START
      while True:
          if proc.poll() is not None:
              if proc.returncode == self._BAD_JAVA_VERSION_RETURN_CODE_:
                  error_message = "Server process terminated because of unsupported Java version"
              else:
                  error_message = (
                      "Server process terminated with error code %d"
                      % proc.returncode
                  )
              if os.stat(self._stderr).st_size > 0:
                  error_message += (
                      ": %s"
                      % open(self._stderr, encoding="utf-8").read()
                  )
              else:
                  error_message += "."
              raise H2OServerError(error_message)
          ret = self._get_server_info_from_logs()
          if ret:
              self._scheme = ret[0]
              self._ip = ret[1]
              self._port = ret[2]
              self._process = proc
              break
          if time.time() > giveup_time:
              elapsed_time = time.time() - (
                  giveup_time - self._TIME_TO_START
              )
              raise H2OServerError(
                  "Server wasn't able to start in %f seconds."
                  % elapsed_time
              )
          time.sleep(0.2)
  
imports: from h2o.utils.compatibility import *
  import atexit
  import os
  import subprocess
  import sys
  import tempfile
  import time
  import re
  from random import choice
  from sysconfig import get_config_var
  from warnings import warn
  from h2o.exceptions import H2OServerError, H2OStartupError, H2OValueError
  from h2o.utils.typechecks import assert_is_type, assert_satisfies, BoundInt, I, is_type
label_desc: Use image node_id 11 for calling the H2OLocalServer obj's underlying member method code with example usage: obj._launch_server(port, baseport, mmax, mmin, ea, nthreads, jvm_custom_args, bind_to_localhost, log_dir, log_level, max_log_file_size) without return types