python - 在 Google App Engine 中部署 python 时出错

标签 python google-app-engine deployment cgi

我正在尝试部署 python 应用程序,但收到以下错误消息:

ERROR: (gcloud.app.deploy) Error Response: [4] Your deployment has failed to become healthy in the allotted time and therefore was rolled back. If you believe this was an error, try adjusting the 'app_start_timeout_sec' setting in the 'readiness_check' section.

我的 app.yaml 是:

runtime: python
runtime_config:
  python_version: 3
env: flex
service: newservice
handlers:
- url: /
  script: hello.py

manual_scaling:
  instances: 1
resources:
  cpu: 1
  memory_gb: 0.5
  disk_size_gb: 10

我相信问题与 yaml 文件有关,因为我之前已经部署了一个示例应用程序,没有任何问题(在我的 yaml 上使用入口点),然后当我添加一个新的 python 脚本并在 yaml 文件上引用它时(使用处理程序来运行我的消息 block )我开始收到此错误。

编辑: 在 GAEFan 回答后,我的问候包含了 readiness_check 的处理程序,如下所示:

def post():
    self.response.headers['Content-Type'] = 'application/json'   
    obj = {
      'status': 200, 
    } 
    self.response.out.write(json.dumps(obj))

webapp2.WSGIApplication([
    ('/readiness_check', post())
], debug=True)

最佳答案

默认情况下启用

准备情况检查。因此,您应该为它们设置 url 处理程序。在本例中,GAE 正在向 /readiness_check 发送请求,但您的 app.yaml 没有该网址的处理程序。试试这个:

handlers:
- url: /.*
  script: hello.py

并确保网址返回 200 或类似响应。自定义准备情况检查:

readiness_check:
  path: "/readiness_check"
  check_interval_sec: 5
  timeout_sec: 4
  failure_threshold: 2
  success_threshold: 2
  app_start_timeout_sec: 300

或者:

liveness_check:
  path: "/liveness_check"
  check_interval_sec: 30
  timeout_sec: 4
  failure_threshold: 2
  success_threshold: 2

详细信息:https://cloud.google.com/appengine/docs/flexible/custom-runtimes/configuring-your-app-with-app-yaml#legacy_health_checks

关于python - 在 Google App Engine 中部署 python 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51154452/

相关文章:

python - PysimpleGUI - 简单的动画

java - 在云中每隔几分钟运行一次 Java 应用程序的最佳方式?

java - 域模式下jboss中的虚拟部署目录

sql - 将 SQL 部署脚本构建到应用程序中?

deployment - 用我的 Windows CE 应用程序替换手持设备的自定义仪表板

python - python 中的单元测试 : ignore an import from the code I want to test

python - 我可以通过编译来提高 python 运行时吗?

Python3列表切片: specific use in class method

java - 新组件的 ReSTLet web.xml 配置

android - 使用带有 Retrofit 的 Robospice 将图像上传到 Google appengine