在 Google App Engine 中部署 python 时出错
Error while deploying python in Google App Engine
我正在尝试部署 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 文件上(使用处理程序,运行 我的消息块)我开始收到此错误。
编辑:
在 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 returns 是 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
您 运行 在灵活环境应用中,handlers
配置是标准环境应用。您需要为柔性环境使用 entrypoint
配置。来自 Application startup:
The runtime starts your application using the entrypoint
defined in
app.yaml
. The entrypoint should start a process that responds
to HTTP requests on the port defined by the environment variable
PORT
.
没有它,您的应用将无法正常运行,无法满足健康检查请求。
可能有用:
我正在尝试部署 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 文件上(使用处理程序,运行 我的消息块)我开始收到此错误。
编辑: 在 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 returns 是 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
您 运行 在灵活环境应用中,handlers
配置是标准环境应用。您需要为柔性环境使用 entrypoint
配置。来自 Application startup:
The runtime starts your application using the
entrypoint
defined inapp.yaml
. The entrypoint should start a process that responds to HTTP requests on the port defined by the environment variablePORT
.
没有它,您的应用将无法正常运行,无法满足健康检查请求。
可能有用: