端点quickstart-app-engine用于Python部署错误

时间:2018-01-09 21:12:03

标签: python google-app-engine google-cloud-endpoints

我尝试按照找到here的分步教程,但部署不起作用,始终返回gcloud app deploy

我没有更改示例代码本身的任何内容。正如我所说,我只是仔细地关注了链接的教程。当我尝试gcloud app deploy --verbosity debug时,它会失败并返回上面的错误。

使用Updating service [default] (this may take several minutes)...failed. DEBUG: (gcloud.app.deploy) Error Response: [13] An internal error occurred Traceback (most recent call last): File "/Users/jamesmiranda/Documents/google-cloud-sdk/lib/googlecloudsdk/calliope/cli.py", line 791, in Execute resources = calliope_command.Run(cli=self, args=args) File "/Users/jamesmiranda/Documents/google-cloud-sdk/lib/googlecloudsdk/calliope/backend.py", line 756, in Run resources = command_instance.Run(args) File "/Users/jamesmiranda/Documents/google-cloud-sdk/lib/surface/app/deploy.py", line 65, in Run parallel_build=False) File "/Users/jamesmiranda/Documents/google-cloud-sdk/lib/googlecloudsdk/command_lib/app/deploy_util.py", line 587, in RunDeploy flex_image_build_option=flex_image_build_option) File "/Users/jamesmiranda/Documents/google-cloud-sdk/lib/googlecloudsdk/command_lib/app/deploy_util.py", line 395, in Deploy extra_config_settings) File "/Users/jamesmiranda/Documents/google-cloud-sdk/lib/googlecloudsdk/api_lib/app/appengine_api_client.py", line 188, in DeployService message=message) File "/Users/jamesmiranda/Documents/google-cloud-sdk/lib/googlecloudsdk/api_lib/app/operations_util.py", line 244, in WaitForOperation sleep_ms=retry_interval) File "/Users/jamesmiranda/Documents/google-cloud-sdk/lib/googlecloudsdk/api_lib/util/waiter.py", line 266, in WaitFor sleep_ms=sleep_ms) File "/Users/jamesmiranda/Documents/google-cloud-sdk/lib/googlecloudsdk/core/util/retry.py", line 222, in RetryOnResult if not should_retry(result, state): File "/Users/jamesmiranda/Documents/google-cloud-sdk/lib/googlecloudsdk/api_lib/util/waiter.py", line 260, in _IsNotDone return not poller.IsDone(operation) File "/Users/jamesmiranda/Documents/google-cloud-sdk/lib/googlecloudsdk/api_lib/app/operations_util.py", line 169, in IsDone encoding.MessageToPyValue(operation.error))) OperationError: Error Response: [13] An internal error occurred ERROR: (gcloud.app.deploy) Error Response: [13] An internal error occurred 会带来一些堆栈跟踪,但没有任何有用的含义。我在下面复制是为了完整性:

runtime: python
env: flex
entrypoint: gunicorn -b :$PORT main:app

runtime_config:
  python_version: 3

# [START configuration]
endpoints_api_service:
  # The following values are to be replaced by information from the output of
  # 'gcloud endpoints services deploy openapi-appengine.yaml' command.
  name:  echo-api.endpoints.MYAPPID.cloud.goog
  config_id: [2018-01-09r1]
 # [END configuration]

下面是app.yaml(与示例git完全相同,APPID除外):

skip_files:

到目前为止我尝试了什么:

  • 将python版本更改为python 2(python_version:2);
  • 在app.yaml中包含一些要跳过的文件(从标准env tutorial中的端点框架复制);

    - ^(.*/)?#.*#$

    - ^(.*/)?.*~$

    - ^(.*/)?.*\.py[co]$

    - ^(.*/)?.*/RCS/.*$

    - ^(.*/)?\..*$

    - ^(.*/)?setuptools/script \(dev\).tmpl$

    from bs4 import BeautifulSoup as parser with open("test.html", "r") as readFile: htmlSource = readFile.read() soup = parser(htmlSource, "html.parser") htmlTags = soup.find_all("html") for eachTag in htmlTags: eachTag.attrs["id"] = htmlTags.index(eachTag) with open("out.html", "w") as saveFile: saveFile.write(str(soup))

  • 尝试了here;

    的解决方法

    gcloud config set app / use_deprecated_preparation True

一切正常。我做错了什么?

注意:

  • README信息
  • 之后,它在本地工作正常
  • 所有内容均适用于GAE标准环境this another tutorial;
  • 我没有在端点本身发现任何问题(我可以看到它部署在API资源管理器中),但是应用程序部署无法以任何方式工作。

1 个答案:

答案 0 :(得分:2)

如果您使用的app.yaml文件与您在问题中复制的文件完全相同,那么您输入的名称和配置ID似乎有错误。根据您的问题中提供的信息,您的app.yaml应如下所示:

runtime: python
env: flex
entrypoint: gunicorn -b :$PORT main:app

runtime_config:
  python_version: 3

# [START configuration]
endpoints_api_service:
  # The following values are to be replaced by information from the output of
  # 'gcloud endpoints services deploy openapi-appengine.yaml' command.
  name:  "echo-api.endpoints.MYAPPID.cloud.goog"
  config_id: "2018-01-09r1"
 # [END configuration]

请注意,您没有在引号内输入name和config_id的值,也不应在括号内输入config_id。

我自己尝试过并且工作正常。如果它仍然不适合你,也许你的名字不正确,因为格式似乎是:

  • " example-project.appspot.com"

因此,如果您的项目ID是ie-project-id,那么您的名字将如下所示:

"my-project-id.appspot.com"