コード例 #1
0
def main():
    """Parses command line options and launches the API server."""
    shutdown.install_signal_handlers()

    # Initialize logging early -- otherwise some library packages may
    # pre-empt our log formatting.  NOTE: the level is provisional; it may
    # be changed based on the --debug flag.
    logging.basicConfig(
        level=logging.INFO,
        format=
        '%(levelname)-8s %(asctime)s %(filename)s:%(lineno)s] %(message)s')

    options = cli_parser.create_command_line_parser(
        cli_parser.API_SERVER_CONFIGURATION).parse_args()
    logging.getLogger().setLevel(constants.LOG_LEVEL_TO_PYTHON_CONSTANT[
        options.dev_appserver_log_level])

    # Parse the application configuration if config_paths are provided, else
    # provide sensible defaults.
    if options.config_paths:
        app_config = application_configuration.ApplicationConfiguration(
            options.config_paths, options.app_id)
        app_id = app_config.app_id
        app_root = app_config.modules[0].application_root
    else:
        app_id = (options.app_id
                  if options.app_id else DEFAULT_API_SERVER_APP_ID)
        app_root = tempfile.mkdtemp()

    # pylint: disable=protected-access
    # TODO: Rename LocalFakeDispatcher or re-implement for api_server.py.
    request_info = wsgi_request_info.WSGIRequestInfo(
        request_info_lib._LocalFakeDispatcher())
    # pylint: enable=protected-access

    os.environ['APPLICATION_ID'] = app_id
    os.environ['APPNAME'] = app_id
    os.environ['NGINX_HOST'] = options.nginx_host

    def request_context(environ):
        return request_info.request(environ, None)

    server = create_api_server(request_info=request_info,
                               storage_path=get_storage_path(
                                   options.storage_path, app_id),
                               options=options,
                               app_id=app_id,
                               app_root=app_root,
                               request_context=request_context)

    if options.pidfile:
        with open(options.pidfile, 'w') as pidfile:
            pidfile.write(str(os.getpid()))

    try:
        server.start()
        shutdown.wait_until_shutdown()
    finally:
        server.quit()
コード例 #2
0
ファイル: api_server.py プロジェクト: venky6363/appscale
def main():
    """Parses command line options and launches the API server."""
    shutdown.install_signal_handlers()

    options = cli_parser.create_command_line_parser(
        cli_parser.API_SERVER_CONFIGURATION).parse_args()
    logging.getLogger().setLevel(constants.LOG_LEVEL_TO_PYTHON_CONSTANT[
        options.dev_appserver_log_level])

    # Parse the application configuration if config_paths are provided, else
    # provide sensible defaults.
    if options.config_paths:
        app_config = application_configuration.ApplicationConfiguration(
            options.config_paths, options.app_id)
        app_id = app_config.app_id
        app_root = app_config.modules[0].application_root
    else:
        app_id = (options.app_id
                  if options.app_id else DEFAULT_API_SERVER_APP_ID)
        app_root = tempfile.mkdtemp()

    # pylint: disable=protected-access
    # TODO: Rename LocalFakeDispatcher or re-implement for api_server.py.
    request_info = wsgi_request_info.WSGIRequestInfo(
        request_info_lib._LocalFakeDispatcher())
    # pylint: enable=protected-access

    os.environ['APPNAME'] = app_id
    os.environ['NGINX_HOST'] = options.nginx_host

    server = create_api_server(request_info=request_info,
                               storage_path=get_storage_path(
                                   options.storage_path, app_id),
                               options=options,
                               app_id=app_id,
                               app_root=app_root)

    try:
        server.start()
        shutdown.wait_until_shutdown()
    finally:
        server.quit()
コード例 #3
0
ファイル: api_server.py プロジェクト: obino/appscale
def main():
  """Parses command line options and launches the API server."""
  shutdown.install_signal_handlers()

  options = cli_parser.create_command_line_parser(
      cli_parser.API_SERVER_CONFIGURATION).parse_args()
  logging.getLogger().setLevel(
      constants.LOG_LEVEL_TO_PYTHON_CONSTANT[options.dev_appserver_log_level])

  # Parse the application configuration if config_paths are provided, else
  # provide sensible defaults.
  if options.config_paths:
    app_config = application_configuration.ApplicationConfiguration(
        options.config_paths, options.app_id)
    app_id = app_config.app_id
    app_root = app_config.modules[0].application_root
  else:
    app_id = (options.app_id if
              options.app_id else DEFAULT_API_SERVER_APP_ID)
    app_root = tempfile.mkdtemp()

  # pylint: disable=protected-access
  # TODO: Rename LocalFakeDispatcher or re-implement for api_server.py.
  request_info = wsgi_request_info.WSGIRequestInfo(
      request_info_lib._LocalFakeDispatcher())
  # pylint: enable=protected-access

  os.environ['APPNAME'] = app_id
  os.environ['NGINX_HOST'] = options.nginx_host

  server = create_api_server(
      request_info=request_info,
      storage_path=get_storage_path(options.storage_path, app_id),
      options=options, app_id=app_id, app_root=app_root)

  try:
    server.start()
    shutdown.wait_until_shutdown()
  finally:
    server.quit()
コード例 #4
0
from google.appengine.tools.devappserver2 import dispatcher
from google.appengine.tools.devappserver2 import metrics
from google.appengine.tools.devappserver2 import runtime_config_pb2
from google.appengine.tools.devappserver2 import shutdown
from google.appengine.tools.devappserver2 import update_checker
from google.appengine.tools.devappserver2 import wsgi_request_info
from google.appengine.tools.devappserver2.admin import admin_server

# Initialize logging early -- otherwise some library packages may
# pre-empt our log formatting.  NOTE: the level is provisional; it may
# be changed in main() based on the --dev_appserver_log_level flag.
logging.basicConfig(
    level=logging.INFO,
    format='%(levelname)-8s %(asctime)s %(filename)s:%(lineno)s] %(message)s')

PARSER = cli_parser.create_command_line_parser(
    cli_parser.DEV_APPSERVER_CONFIGURATION)


def _setup_environ(app_id):
    """Sets up the os.environ dictionary for the front-end server and API server.

  This function should only be called once.

  Args:
    app_id: The id of the application.
  """
    os.environ['APPLICATION_ID'] = app_id


class DevelopmentServer(object):
    """Encapsulates the logic for the development server.
コード例 #5
0
        try:
            user_name = getpass.getuser()
        except Exception:  # pylint: disable=broad-except
            # The possible set of exceptions is not documented.
            user_format = ''
        else:
            user_format = '.%s' % user_name

    tempdir = tempfile.gettempdir()
    yield os.path.join(tempdir, 'appengine.%s%s' % (app_id, user_format))
    for i in itertools.count(1):
        yield os.path.join(tempdir,
                           'appengine.%s%s.%d' % (app_id, user_format, i))


PARSER = cli_parser.create_command_line_parser(
    cli_parser.API_SERVER_CONFIGURATION)


def main():
    """Parses command line options and launches the API server."""
    shutdown.install_signal_handlers()

    options = PARSER.parse_args()
    logging.getLogger().setLevel(constants.LOG_LEVEL_TO_PYTHON_CONSTANT[
        options.dev_appserver_log_level])

    # Parse the application configuration if config_paths are provided, else
    # provide sensible defaults.
    if options.config_paths:
        app_config = application_configuration.ApplicationConfiguration(
            options.config_paths, options.app_id)
コード例 #6
0
ファイル: api_server.py プロジェクト: jsa/gaesdk-python
  else:
    try:
      user_name = getpass.getuser()
    except Exception:  # pylint: disable=broad-except
      # The possible set of exceptions is not documented.
      user_format = ''
    else:
      user_format = '.%s' % user_name

  tempdir = tempfile.gettempdir()
  yield os.path.join(tempdir, 'appengine.%s%s' % (app_id, user_format))
  for i in itertools.count(1):
    yield os.path.join(tempdir, 'appengine.%s%s.%d' % (app_id, user_format, i))


PARSER = cli_parser.create_command_line_parser(
    cli_parser.API_SERVER_CONFIGURATION)


def main():
  """Parses command line options and launches the API server."""
  shutdown.install_signal_handlers()

  options = PARSER.parse_args()
  logging.getLogger().setLevel(
      constants.LOG_LEVEL_TO_PYTHON_CONSTANT[options.dev_appserver_log_level])

  # Parse the application configuration if config_paths are provided, else
  # provide sensible defaults.
  if options.config_paths:
    app_config = application_configuration.ApplicationConfiguration(
        options.config_paths, options.app_id)
コード例 #7
0
from google.appengine.tools.devappserver2 import metrics
from google.appengine.tools.devappserver2 import runtime_config_pb2
from google.appengine.tools.devappserver2 import shutdown
from google.appengine.tools.devappserver2 import update_checker
from google.appengine.tools.devappserver2 import wsgi_request_info
from google.appengine.tools.devappserver2.admin import admin_server

# Initialize logging early -- otherwise some library packages may
# pre-empt our log formatting.  NOTE: the level is provisional; it may
# be changed in main() based on the --dev_appserver_log_level flag.
logging.basicConfig(
    level=logging.INFO,
    format='%(levelname)-8s %(asctime)s %(filename)s:%(lineno)s] %(message)s')


PARSER = cli_parser.create_command_line_parser(
    cli_parser.DEV_APPSERVER_CONFIGURATION)


def _setup_environ(app_id):
  """Sets up the os.environ dictionary for the front-end server and API server.

  This function should only be called once.

  Args:
    app_id: The id of the application.
  """
  os.environ['APPLICATION_ID'] = app_id


class DevelopmentServer(object):
  """Encapsulates the logic for the development server.
コード例 #8
0
from google.appengine.tools.devappserver2 import dispatcher
from google.appengine.tools.devappserver2 import metrics
from google.appengine.tools.devappserver2 import runtime_config_pb2
from google.appengine.tools.devappserver2 import shutdown
from google.appengine.tools.devappserver2 import update_checker
from google.appengine.tools.devappserver2 import wsgi_request_info
from google.appengine.tools.devappserver2.admin import admin_server

# Initialize logging early -- otherwise some library packages may
# pre-empt our log formatting.  NOTE: the level is provisional; it may
# be changed in main() based on the --debug flag.
logging.basicConfig(
    level=logging.INFO,
    format='%(levelname)-8s %(asctime)s %(filename)s:%(lineno)s] %(message)s')

PARSER = cli_parser.create_command_line_parser()


def _setup_environ(app_id):
    """Sets up the os.environ dictionary for the front-end server and API server.

  This function should only be called once.

  Args:
    app_id: The id of the application.
  """
    os.environ['APPLICATION_ID'] = app_id


class DevelopmentServer(object):
    """Encapsulates the logic for the development server.