我正在尝试部署 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
关于python - 在 Google App Engine 中部署 python 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51154452/