无法访问健康检查

Can't access health check

我目前正在使用 Django 开发网络应用程序。我使用了这个 app.yaml 并在 google 应用程序引擎上成功部署。但是,我无法访问 /_hc,因为 Django 会检查 url 是否在 url 模式中并且它只是响应 'Page not found'。我该如何解决这个问题?

runtime: python37
entrypoint: bash -c 'gunicorn -b :$PORT projectservice.wsgi'
liveness_check:
  path: "/_hc"
  check_interval_sec: 30
  timeout_sec: 4
  failure_threshold: 2
  success_threshold: 2
handlers:
# This configures Google App Engine to serve the files in the app's
# static directory.
- url: /static
  static_dir: static/
# This handler routes all requests not caught above to the main app. 
# It is required when static routes are defined, but can be omitted 
# (along with the entire handlers section) when there are no static 
# files defined.
- url: /.*
  script: auto
# [END django_app]

这很好,但是您需要有一个 /_hc 的 url 处理程序,returns 一个 200 响应:

from django.http import HttpResponse

def health_check_handler(request):
    return HttpResponse("healthy", content_type='text/plain')

在urls.py中:

(r'^_hc$', 'health_check_handler'),