简体   繁体   English

如何使用带有Python的Google App Engine开发服务器运行两个版本的应用程序

[英]How to run two versions of an application using Google App Engine dev server with Python

I am using Ubuntu Server 13.10 and Python 2.7. 我使用的是Ubuntu Server 13.10和Python 2.7。

I would like to have two versions of my App Engine application: admin and the default version. 我想有两个版本的App Engine应用程序:admin和默认版本。 I have defined these two versions. 我已经定义了这两个版本。 Currently, this is my app.yaml file: 目前,这是我的app.yaml文件:

application: application-id
version: 1
runtime: python27
api_version: 1
threadsafe: true

handlers:
- url: /css
  static_dir: css
- url: /js
  static_dir: js
- url: /
  script: python.MainPage.application
- url: /test.*
  script: gaeunit.application

libraries:
- name: webapp2
  version: latest
- name: jinja2
  version: latest


version: admin
runtime: python27
api_version: 1
threadsafe: true

handlers:
- url: /css
  static_dir: css
- url: /js
  static_dir: js
- url: /.*
  script: python.MainPage.application
  login: admin
  auth_fail_action: unauthorized
- url: /test.*
  script: python.MainPage.appication

libraries:
- name: webapp2
  version: latest
- name: jinja2
  version: latest

When I deploy this code to App Engine, it works as expected. 当我将此代码部署到App Engine时,它按预期工作。 However, If I attempt to run it using dev_appserver.py found in the Google Cloud SDK, it fails with this traceback: 但是,如果我尝试使用Google Cloud SDK中的dev_appserver.py运行它,则会因此追溯而失败:

Traceback (most recent call last):
  File "/home/katie/google-cloud-sdk/platform/google_appengine/dev_appserver.py", line 82, in <module>
    _run_file(__file__, globals())
  File "/home/katie/google-cloud-sdk/platform/google_appengine/dev_appserver.py", line 78, in _run_file
    execfile(_PATHS.script_file(script_name), globals_)
  File "/home/katie/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 902, in <module>
    main()
  File "/home/katie/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 895, in main
    dev_server.start(options)
  File "/home/katie/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 672, in start
    options.yaml_files)
  File "/home/katie/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/application_configuration.py", line 556, in __init__
    module_configuration = ModuleConfiguration(yaml_path)
  File "/home/katie/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/application_configuration.py", line 82, in __init__
    self._yaml_path)
  File "/home/katie/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/application_configuration.py", line 272, in _parse_configuration
    return appinfo_includes.ParseAndReturnIncludePaths(f)
  File "/home/katie/google-cloud-sdk/platform/google_appengine/google/appengine/api/appinfo_includes.py", line 63, in ParseAndReturnIncludePaths
    appyaml = appinfo.LoadSingleAppInfo(appinfo_file)
  File "/home/katie/google-cloud-sdk/platform/google_appengine/google/appengine/api/appinfo.py", line 1826, in LoadSingleAppInfo
    listener.Parse(app_info)
  File "/home/katie/google-cloud-sdk/platform/google_appengine/google/appengine/api/yaml_listener.py", line 226, in Parse
    self._HandleEvents(self._GenerateEventParameters(stream, loader_class))
  File "/home/katie/google-cloud-sdk/platform/google_appengine/google/appengine/api/yaml_listener.py", line 177, in _HandleEvents
    raise yaml_errors.EventError(e, event_object)
google.appengine.api.yaml_errors.EventError: Duplicate attribute 'version'.
  in "aerobic-arcade-514/default/app.yaml", line 24, column 10

You can launch two different dev app servers on two different ports, just override the default port with the --port= parameter, however you will need to have two app.yaml files separated, not using the same file as you did. 您可以在两个不同的端口上启动两个不同的开发应用服务器,只需使用--port=参数覆盖默认端口,但是您需要将两个app.yaml文件分开,而不是使用与您相同的文件。 When you run dev_appserver.py , use the config file as the final argument instead of the directory (which defaults to app.yaml ). 运行dev_appserver.py ,请使用配置文件作为最终参数,而不是目录(默认为app.yaml )。

For example: 例如:

dev_appserver.py --port=8888 app_one.yaml
dev_appserver.py --port=9999 app_two.yaml

After your testing and before deploying, make sure you leave the definitive file with the name app.yaml ; 在测试之后和部署之前,请确保保留名为app.yaml的最终文件; otherwise, you won't be able to complete the process. 否则,您将无法完成此过程。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从谷歌应用引擎开发应用服务器批量下载 - How to bulk download from google app engine dev app server 将Flask与Google App Engine开发服务器配合使用,找不到swagger ui吗? - Using Flask with Google App Engine Dev Server, swagger ui not found? 如何使用Python在Google App Engine中使用应用程序部署映像 - How to Deploy an Image with the Application in Google App Engine Using Python 在Google App Engine开发服务器上访问BigQuery - Accessing BigQuery on Google App Engine dev server 如何在本地运行python +谷歌应用程序引擎应用程序,但指向实时谷歌数据存储? - How to run python + google app engine application locally but pointing to live google datastore? 在Google App Engine(Python)中,如何增加应用程序服务器的资源? - In Google App Engine (Python), how do you boost the resources of your application server? 如何在 Windows 上正确运行 Google 应用引擎 web 服务器? - How to run Google app engine web server on Windows correct? 使用Google App Engine开发服务器和mysql的Django Modal save()函数未实现 - Django Modal save() function not implemented, using google app engine dev server and mysql 使用谷歌应用引擎部署基于控制台的 python 应用程序 - Deploy console based python application using google app engine 使用微服务运行Google App Engine应用程序 - Run Google App Engine application with microservice
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM