コード例 #1
0
 def _create_python_config(options):
     python_config = runtime_config_pb2.PythonConfig()
     if options.python_startup_script:
         python_config.startup_script = os.path.abspath(
             options.python_startup_script)
         if options.python_startup_args:
             python_config.startup_args = options.python_startup_args
     return python_config
コード例 #2
0
 def _create_python_config(options, grpc_proxy_port=None):
     python_config = runtime_config_pb2.PythonConfig()
     if options.python_startup_script:
         python_config.startup_script = os.path.abspath(
             options.python_startup_script)
         if options.python_startup_args:
             python_config.startup_args = options.python_startup_args
     if grpc_proxy_port:
         python_config.grpc_proxy_port = grpc_proxy_port
     return python_config
コード例 #3
0
ファイル: devappserver2.py プロジェクト: amir8256/appscale
    def start(self, options):
        """Start devappserver2 servers based on the provided command line arguments.

    Args:
      options: An argparse.Namespace containing the command line arguments.
    """
        logging.getLogger().setLevel(constants.LOG_LEVEL_TO_PYTHON_CONSTANT[
            options.dev_appserver_log_level])

        configuration = application_configuration.ApplicationConfiguration(
            options.config_paths, options.app_id)

        if options.skip_sdk_update_check:
            logging.info('Skipping SDK update check.')
        else:
            update_checker.check_for_updates(configuration)

        if options.port == 0:
            logging.warn(
                'DEFAULT_VERSION_HOSTNAME will not be set correctly with '
                '--port=0')

        _setup_environ(configuration.app_id,
                       configuration.modules[0].version_id)

        python_config = runtime_config_pb2.PythonConfig()
        if options.python_startup_script:
            python_config.startup_script = os.path.abspath(
                options.python_startup_script)
            if options.python_startup_args:
                python_config.startup_args = options.python_startup_args

        php_executable_path = (options.php_executable_path and os.path.abspath(
            options.php_executable_path))
        cloud_sql_config = runtime_config_pb2.CloudSQL()
        cloud_sql_config.mysql_host = options.mysql_host
        cloud_sql_config.mysql_port = options.mysql_port
        cloud_sql_config.mysql_user = options.mysql_user
        cloud_sql_config.mysql_password = options.mysql_password
        if options.mysql_socket:
            cloud_sql_config.mysql_socket = options.mysql_socket

        if options.max_module_instances is None:
            module_to_max_instances = {}
        elif isinstance(options.max_module_instances, int):
            module_to_max_instances = {
                module_configuration.module_name: options.max_module_instances
                for module_configuration in configuration.modules
            }
        else:
            module_to_max_instances = options.max_module_instances

        if options.threadsafe_override is None:
            module_to_threadsafe_override = {}
        elif isinstance(options.threadsafe_override, bool):
            module_to_threadsafe_override = {
                module_configuration.module_name: options.threadsafe_override
                for module_configuration in configuration.modules
            }
        else:
            module_to_threadsafe_override = options.threadsafe_override

        self._dispatcher = dispatcher.Dispatcher(
            configuration, options.host, options.port, options.auth_domain,
            constants.LOG_LEVEL_TO_RUNTIME_CONSTANT[options.log_level],
            php_executable_path, options.php_remote_debugging, python_config,
            cloud_sql_config, module_to_max_instances,
            options.use_mtime_file_watcher, options.automatic_restart,
            options.allow_skipped_files, module_to_threadsafe_override,
            options.external_api_port)

        request_data = wsgi_request_info.WSGIRequestInfo(self._dispatcher)
        storage_path = api_server.get_storage_path(options.storage_path,
                                                   configuration.app_id)

        apis = api_server.create_api_server(
            request_data, storage_path, options, configuration.app_id,
            configuration.modules[0].application_root)
        apis.start()
        self._running_modules.append(apis)

        self._dispatcher.start(apis.port, request_data)
        self._running_modules.append(self._dispatcher)

        xsrf_path = os.path.join(storage_path, 'xsrf')
        admin = admin_server.AdminServer(options.admin_host,
                                         options.admin_port, self._dispatcher,
                                         configuration, xsrf_path)
        admin.start()
        self._running_modules.append(admin)
コード例 #4
0
ファイル: devappserver2.py プロジェクト: bawelleme/appscale
  def start(self, options):
    """Start devappserver2 servers based on the provided command line arguments.

    Args:
      options: An argparse.Namespace containing the command line arguments.
    """
    logging.getLogger().setLevel(
        _LOG_LEVEL_TO_PYTHON_CONSTANT[options.dev_appserver_log_level])

    configuration = application_configuration.ApplicationConfiguration(
        options.yaml_files, options.app_id)

    if options.skip_sdk_update_check:
      logging.info('Skipping SDK update check.')
    else:
      update_checker.check_for_updates(configuration)

    if options.port == 0:
      logging.warn('DEFAULT_VERSION_HOSTNAME will not be set correctly with '
                   '--port=0')

    _setup_environ(configuration.app_id, configuration.modules[0].version_id)

    python_config = runtime_config_pb2.PythonConfig()
    if options.python_startup_script:
      python_config.startup_script = os.path.abspath(
          options.python_startup_script)
      if options.python_startup_args:
        python_config.startup_args = options.python_startup_args

    cloud_sql_config = runtime_config_pb2.CloudSQL()
    cloud_sql_config.mysql_host = options.mysql_host
    cloud_sql_config.mysql_port = options.mysql_port
    cloud_sql_config.mysql_user = options.mysql_user
    cloud_sql_config.mysql_password = options.mysql_password
    if options.mysql_socket:
      cloud_sql_config.mysql_socket = options.mysql_socket

    if options.max_module_instances is None:
      module_to_max_instances = {}
    elif isinstance(options.max_module_instances, int):
      module_to_max_instances = {
          module_configuration.module_name: options.max_module_instances
          for module_configuration in configuration.modules}
    else:
      module_to_max_instances = options.max_module_instances

    self._dispatcher = dispatcher.Dispatcher(
        configuration,
        options.host,
        options.port,
        options.auth_domain,
        _LOG_LEVEL_TO_RUNTIME_CONSTANT[options.log_level],
        options.php_executable_path,
        options.php_remote_debugging,
        python_config,
        cloud_sql_config,
        module_to_max_instances,
        options.use_mtime_file_watcher,
        options.automatic_restart,
        options.allow_skipped_files,
        options.external_api_port)
    request_data = wsgi_request_info.WSGIRequestInfo(self._dispatcher)

    storage_path = _get_storage_path(options.storage_path, configuration.app_id)
    datastore_path = options.datastore_path or os.path.join(storage_path,
                                                            'datastore.db')
    logs_path = options.logs_path or os.path.join(storage_path, 'logs.db')
    xsrf_path = os.path.join(storage_path, 'xsrf')

    search_index_path = options.search_indexes_path or os.path.join(
        storage_path, 'search_indexes')

    prospective_search_path = options.prospective_search_path or os.path.join(
        storage_path, 'prospective-search')

    blobstore_path = options.blobstore_path or os.path.join(storage_path,
                                                            'blobs')

    if options.clear_datastore:
      _clear_datastore_storage(datastore_path)

    if options.clear_prospective_search:
      _clear_prospective_search_storage(prospective_search_path)

    if options.clear_search_indexes:
      _clear_search_indexes_storage(search_index_path)

    if options.auto_id_policy==datastore_stub_util.SEQUENTIAL:
      logging.warn("--auto_id_policy='sequential' is deprecated. This option "
                   "will be removed in a future release.")

    application_address = '%s' % options.host
    if options.port and options.port != 80:
      application_address += ':' + str(options.port)

    user_login_url = '/%s?%s=%%s' % (login.LOGIN_URL_RELATIVE,
                                     login.CONTINUE_PARAM)
    user_logout_url = '%s&%s=%s' % (user_login_url, login.ACTION_PARAM,
                                    login.LOGOUT_ACTION)

    if options.datastore_consistency_policy == 'time':
      consistency = datastore_stub_util.TimeBasedHRConsistencyPolicy()
    elif options.datastore_consistency_policy == 'random':
      consistency = datastore_stub_util.PseudoRandomHRConsistencyPolicy()
    elif options.datastore_consistency_policy == 'consistent':
      consistency = datastore_stub_util.PseudoRandomHRConsistencyPolicy(1.0)
    else:
      assert 0, ('unknown consistency policy: %r' %
                 options.datastore_consistency_policy)

    api_server.maybe_convert_datastore_file_stub_data_to_sqlite(
        configuration.app_id, datastore_path)
    api_server.setup_stubs(
        request_data=request_data,
        app_id=configuration.app_id,
        application_root=configuration.modules[0].application_root,
        # The "trusted" flag is only relevant for Google administrative
        # applications.
        trusted=getattr(options, 'trusted', False),
        blobstore_path=blobstore_path,
        datastore_path=datastore_path,
        datastore_consistency=consistency,
        datastore_require_indexes=options.require_indexes,
        datastore_auto_id_policy=options.auto_id_policy,
        images_host_prefix='http://%s' % application_address,
        logs_path=logs_path,
        mail_smtp_host=options.smtp_host,
        mail_smtp_port=options.smtp_port,
        mail_smtp_user=options.smtp_user,
        mail_smtp_password=options.smtp_password,
        mail_enable_sendmail=options.enable_sendmail,
        mail_show_mail_body=options.show_mail_body,
        matcher_prospective_search_path=prospective_search_path,
        search_index_path=search_index_path,
        taskqueue_auto_run_tasks=options.enable_task_running,
        taskqueue_default_http_server=application_address,
        uaserver_path=options.uaserver_path,
        user_login_url=user_login_url,
        user_logout_url=user_logout_url,
        xmpp_path=options.xmpp_path)

    # The APIServer must bind to localhost because that is what the runtime
    # instances talk to.
    apis = api_server.APIServer('localhost', options.api_port,
                                configuration.app_id)
    apis.start()
    self._running_modules.append(apis)

    self._running_modules.append(self._dispatcher)
    self._dispatcher.start(apis.port, request_data)

    admin = admin_server.AdminServer(options.admin_host, options.admin_port,
                                     self._dispatcher, configuration, xsrf_path)
    admin.start()
    self._running_modules.append(admin)