def __init__(self, configuration, host, port, runtime_stderr_loglevel, python_config, cloud_sql_config, server_to_max_instances, use_mtime_file_watcher, automatic_restart): """Initializer for Dispatcher. Args: configuration: An application_configuration.ApplicationConfiguration instance storing the configuration data for the app. host: A string containing the host that any HTTP servers should bind to e.g. "localhost". port: An int specifying the first port where servers should listen. runtime_stderr_loglevel: An int reprenting the minimum logging level at which runtime log messages should be written to stderr. See devappserver2.py for possible values. python_config: A runtime_config_pb2.PythonConfig instance containing Python runtime-specific configuration. If None then defaults are used. cloud_sql_config: A runtime_config_pb2.CloudSQL instance containing the required configuration for local Google Cloud SQL development. If None then Cloud SQL will not be available. server_to_max_instances: A mapping between a server name and the maximum number of instances that can be created (this overrides the settings found in the configuration argument) e.g. {'default': 10, 'backend': 15}. use_mtime_file_watcher: A bool containing whether to use mtime polling to monitor file changes even if other options are available on the current platform. automatic_restart: If True then instances will be restarted when a file or configuration change that effects them is detected. """ self._configuration = configuration self._python_config = python_config self._cloud_sql_config = cloud_sql_config self._request_data = None self._api_port = None self._running_servers = [] self._server_configurations = {} self._host = host self._port = port self._runtime_stderr_loglevel = runtime_stderr_loglevel self._server_name_to_server = {} self._dispatch_server = None self._quit_event = threading.Event( ) # Set when quit() has been called. self._update_checking_thread = threading.Thread( target=self._loop_checking_for_updates) self._server_to_max_instances = server_to_max_instances or {} self._use_mtime_file_watcher = use_mtime_file_watcher self._automatic_restart = automatic_restart self._executor = scheduled_executor.ScheduledExecutor(_THREAD_POOL) self._port_registry = PortRegistry()
def setUp(self): self.executor = scheduled_executor.ScheduledExecutor(FakeThreadPool()) self.executor.start()
def __init__(self, configuration, host, port, auth_domain, runtime_stderr_loglevel, php_config, python_config, java_config, go_config, custom_config, cloud_sql_config, vm_config, module_to_max_instances, use_mtime_file_watcher, automatic_restart, allow_skipped_files, module_to_threadsafe_override, external_port): """Initializer for Dispatcher. Args: configuration: An application_configuration.ApplicationConfiguration instance storing the configuration data for the app. host: A string containing the host that any HTTP servers should bind to e.g. "localhost". port: An int specifying the first port where servers should listen. auth_domain: A string containing the auth domain to set in the environment variables. runtime_stderr_loglevel: An int reprenting the minimum logging level at which runtime log messages should be written to stderr. See devappserver2.py for possible values. php_config: A runtime_config_pb2.PhpConfig instances containing PHP runtime-specific configuration. If None then defaults are used. python_config: A runtime_config_pb2.PythonConfig instance containing Python runtime-specific configuration. If None then defaults are used. java_config: A runtime_config_pb2.JavaConfig instance containing Java runtime-specific configuration. If None then defaults are used. go_config: A runtime_config_pb2.GoConfig instance containing Go runtime-specific configuration. If None then defaults are used. custom_config: A runtime_config_pb2.CustomConfig instance. If None, or 'custom_entrypoint' is not set, then attempting to instantiate a custom runtime module will result in an error. cloud_sql_config: A runtime_config_pb2.CloudSQL instance containing the required configuration for local Google Cloud SQL development. If None then Cloud SQL will not be available. vm_config: A runtime_config_pb2.VMConfig instance containing VM runtime-specific configuration. module_to_max_instances: A mapping between a module name and the maximum number of instances that can be created (this overrides the settings found in the configuration argument) e.g. {'default': 10, 'backend': 15}. use_mtime_file_watcher: A bool containing whether to use mtime polling to monitor file changes even if other options are available on the current platform. automatic_restart: If True then instances will be restarted when a file or configuration change that affects them is detected. allow_skipped_files: If True then all files in the application's directory are readable, even if they appear in a static handler or "skip_files" directive. module_to_threadsafe_override: A mapping between the module name and what to override the module's YAML threadsafe configuration (so modules not named continue to use their YAML configuration). external_port: The port on which the single external module is expected to listen, or None if there are no external modules. This will later be changed so that the association between external modules and their ports is more flexible. """ self._configuration = configuration self._php_config = php_config self._python_config = python_config self._java_config = java_config self._go_config = go_config self._custom_config = custom_config self._cloud_sql_config = cloud_sql_config self._vm_config = vm_config self._request_data = None self._api_host = None self._api_port = None self._running_modules = [] self._module_configurations = {} self._host = host self._port = port self._auth_domain = auth_domain self._runtime_stderr_loglevel = runtime_stderr_loglevel self._module_name_to_module = {} self._dispatch_server = None self._quit_event = threading.Event( ) # Set when quit() has been called. self._update_checking_thread = threading.Thread( target=self._loop_checking_for_updates, name='Dispatcher Update Checking') self._module_to_max_instances = module_to_max_instances or {} self._use_mtime_file_watcher = use_mtime_file_watcher self._automatic_restart = automatic_restart self._allow_skipped_files = allow_skipped_files self._module_to_threadsafe_override = module_to_threadsafe_override self._executor = scheduled_executor.ScheduledExecutor(_THREAD_POOL) self._port_registry = PortRegistry() self._external_port = external_port
def __init__(self, configuration, host, port, auth_domain, runtime_stderr_loglevel, php_executable_path, enable_php_remote_debugging, python_config, cloud_sql_config, module_to_max_instances, use_mtime_file_watcher, automatic_restart, allow_skipped_files, external_api_port=None): """Initializer for Dispatcher. Args: configuration: An application_configuration.ApplicationConfiguration instance storing the configuration data for the app. host: A string containing the host that any HTTP servers should bind to e.g. "localhost". port: An int specifying the first port where servers should listen. auth_domain: A string containing the auth domain to set in the environment variables. runtime_stderr_loglevel: An int reprenting the minimum logging level at which runtime log messages should be written to stderr. See devappserver2.py for possible values. php_executable_path: A string containing the path to PHP execution e.g. "/usr/bin/php-cgi". enable_php_remote_debugging: A boolean indicating whether the PHP interpreter should be started with XDebug remote debugging enabled. python_config: A runtime_config_pb2.PythonConfig instance containing Python runtime-specific configuration. If None then defaults are used. cloud_sql_config: A runtime_config_pb2.CloudSQL instance containing the required configuration for local Google Cloud SQL development. If None then Cloud SQL will not be available. module_to_max_instances: A mapping between a module name and the maximum number of instances that can be created (this overrides the settings found in the configuration argument) e.g. {'default': 10, 'backend': 15}. use_mtime_file_watcher: A bool containing whether to use mtime polling to monitor file changes even if other options are available on the current platform. automatic_restart: If True then instances will be restarted when a file or configuration change that effects them is detected. allow_skipped_files: If True then all files in the application's directory are readable, even if they appear in a static handler or "skip_files" directive. external_api_port: An integer specifying the location of an external API server. """ self._configuration = configuration self._php_executable_path = php_executable_path self._enable_php_remote_debugging = enable_php_remote_debugging self._python_config = python_config self._cloud_sql_config = cloud_sql_config self._request_data = None self._api_port = None self._external_api_port = external_api_port self._running_modules = [] self._module_configurations = {} self._host = host self._port = port self._auth_domain = auth_domain self._runtime_stderr_loglevel = runtime_stderr_loglevel self._module_name_to_module = {} self._dispatch_server = None self._quit_event = threading.Event() # Set when quit() has been called. self._update_checking_thread = threading.Thread( target=self._loop_checking_for_updates) self._module_to_max_instances = module_to_max_instances or {} self._use_mtime_file_watcher = use_mtime_file_watcher self._automatic_restart = automatic_restart self._allow_skipped_files = allow_skipped_files self._executor = scheduled_executor.ScheduledExecutor(_THREAD_POOL) self._port_registry = PortRegistry()