python - 在 Google App Engine 中部署 python 时出错
问题描述
我正在尝试部署 python 应用程序,但收到以下错误消息:
错误:(gcloud.app.deploy)错误响应:[4]您的部署未能在分配的时间内变得健康,因此被回滚。如果您认为这是一个错误,请尝试调整“readiness_check”部分中的“app_start_timeout_sec”设置。
我的 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 文件中引用它时(使用处理程序,运行我的消息块)我开始收到此错误。
编辑:在 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)
解决方案
Readiness checks
默认启用。因此,您应该为它们设置 url 处理程序。在这种情况下,GAE 正在向 发送请求/readiness_check
,但您app.yaml
没有该 url 的处理程序。尝试这个:
handlers:
- url: /.*
script: hello.py
并确保 url 返回一个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
推荐阅读
- javascript - 如何使用 html 将此登录系统放在我的网站上
- c++ - 不同等级的多项式相加
- amazon-web-services - Amazon Cognito 使用具有低支出限制的 Amazon SNS 服务器位置,而不是具有高支出限制的位置
- sql-server - 适用于 SQL Server 2008 的 SSIS Visual Studio 2019
- c# - 从基本响应扩展到 C# MVC 中的模型
- root - 不允许操作 /usr/bin macos catalina
- python - 了解 pandas 中合并的本质
- java - java: package jdk.incubator.foreign 在 Java 15 中是不可见的错误
- python - 如何在矩阵中找到最低 3 个值
- python - 如何构建依赖于其他自定义 python 包的 Python 包?