Ejemplo n.º 1
0
  def __init__(self, docker_client, runtime_config_getter,
               module_configuration):
    """Initializer for VMRuntimeProxy.

    Args:
      docker_client: docker.Client object to communicate with Docker daemon.
      runtime_config_getter: A function that can be called without arguments
          and returns the runtime_config_pb2.Config containing the configuration
          for the runtime.
      module_configuration: An application_configuration.ModuleConfiguration
          instance respresenting the configuration of the module that owns the
          runtime.
    """
    super(GoVMRuntimeProxy, self).__init__()
    self._runtime_config_getter = runtime_config_getter
    self._module_configuration = module_configuration
    port_bindings = {
        DEBUG_PORT: None,
        VM_SERVICE_PORT: None,
    }
    self._vm_runtime_proxy = vm_runtime_proxy.VMRuntimeProxy(
        docker_client=docker_client,
        runtime_config_getter=runtime_config_getter,
        module_configuration=module_configuration,
        port_bindings=port_bindings)
    def __init__(self,
                 docker_client,
                 runtime_config_getter,
                 module_configuration,
                 default_port=8080,
                 port_bindings=None):
        """Initializer for VMRuntimeProxy.

    Args:
      docker_client: docker.Client object to communicate with Docker daemon.
      runtime_config_getter: A function that can be called without arguments
          and returns the runtime_config_pb2.Config containing the configuration
          for the runtime.
      module_configuration: An application_configuration.ModuleConfiguration
          instance respresenting the configuration of the module that owns the
          runtime.
      default_port: int, main port inside of the container that instance is
          listening on.
      port_bindings: dict, Additional port bindings from the container.
    """
        super(DartVMRuntimeProxy, self).__init__()
        self._runtime_config_getter = runtime_config_getter
        self._module_configuration = module_configuration

        if not port_bindings:
            port_bindings = {
                VM_SERVICE_PORT: None,
            }

        # Get the Dart configuration.
        runtime_config = self._runtime_config_getter()
        dart_config = runtime_config.vm_config.dart_config

        # Find the 'pub' executable to use.
        if dart_config.dart_sdk:
            self._pub = os.path.join(dart_config.dart_sdk, 'bin', 'pub')
        else:
            self._pub = 'pub'

        # Get 'pub serve' and mode configuration.
        self._pub_serve_host = dart_config.dart_pub_serve_host
        self._pub_serve_port = dart_config.dart_pub_serve_port
        self._mode = dart_config.dart_dev_mode or DEV_MODE

        additional_environment = None
        if self._use_pub_serve:
            pub_serve = 'http://%s:%s' % (self._pub_serve_host,
                                          self._pub_serve_port)
            additional_environment = {'DART_PUB_SERVE': pub_serve}

        self._vm_runtime_proxy = vm_runtime_proxy.VMRuntimeProxy(
            docker_client=docker_client,
            runtime_config_getter=runtime_config_getter,
            module_configuration=module_configuration,
            default_port=default_port,
            port_bindings=port_bindings,
            additional_environment=additional_environment)