如何为托管虚拟机配置Google App Engine运行状况检查端点 [英] How to configure Google App Engine health checking endpoints for managed VMs

查看:131
本文介绍了如何为托管虚拟机配置Google App Engine运行状况检查端点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我试图部署一个项目,我不是代码维护人员,它将被部署为托管虚拟机,以进行自动调节和健康检查。



目前app.yaml不支持重写规则,如果支持,我可以指向/ _ah /健康到一个/ ping端点。这很好,因为健康检查可以在不改变代码的情况下实现。



在app.yaml中有处理程序的配置,我的理解是处理程序用于google运行时,而不是托管虚拟机。



我想更改/ _ah / health请求的位置。有没有办法做这种改变?因此,假设你有一个健康检查服务端点(使用

code> webapp2 以确定性,其他框架当然也是相同的)在 health.py

  class HealthPage(webapp2.RequestHandler):
def get(self):
self.response.write('< html>< ; body>< p> I \'m fine!< / p>< / body>< / html>')

,不幸的是,你也可以在同一个文件中使用硬编码的路由信息​​(而不是从一个容易修改和推送的配置文件中更正确地读取它):

  application = webapp2.WSGIApplication([
('/ howareyou',HealthPage),
])

现在,要从同一个 HealthPage 处理程序中进行健康检查,您需要编辑你的 app.yaml 使其拥有:

 句柄rs:
- url:/ _ah / health
script:health.application



之前的任何处理程序的 url:当然有可能吞下这个通配符。



现在,由于您的应用程序对象中有严格的硬编码路由决策,因此您必须对其进行编辑。这不是真正的编辑代码 - 它正在编辑配置信息,您不幸地决定将其作为严格的硬编码字符串嵌入到您的代码中,而不是从配置代码中选取。



要么使得代码内路由不那么严格,可能一直到:

  application = webapp2.WSGIApplication([
('。*',HealthPage),
])

或者如果您致力于在代码中使用非常严格的硬编码路由,您可以选择添加一行...:

  application = webapp2.WSGIApplication([
('/ howareyou',HealthPage),
('/ _ah / health',HealthPage),
])

对于其他路由系统(超出 app.yaml 以及其他基于配置的路由由App Engine自己完成)当然 - webapp2 的路由系统没有什么奇怪的,也不是反常的。

注意如果这些编辑被路由到 health.py 在其他()非GAE和非GAE的)部署 - 他们将像以前那样服务。



如果尽管所有这些仍然需要在 app.yaml 中具有URL重写功能,或类似的强大功能,可以处理健康状况检查,同时避免需要这种微小的解决方法,您当然可以打开 https://code.google.com/p/googleappengine/issues/list中的功能请求 - 我无法想象它对那里数以千计的开放问题变得非常紧迫,但是,嘿!,我以前错了: - )。


Google App Engine requests /_ah/health from the managed vm to do health checking.

I trying to deploy a project that I'm not the code maintainer, it's going to be deployed as managed vm to have autoscaling and health checking.

Currently app.yaml doesn't support rewrite rules, if it supported I could point the /_ah/health to a /ping endpoint. This would be great because health checking could be implemented without changing code.

In app.yaml there is the configuration for handlers, my understanding is that handler are for use with the google runtime, not for managed VMs.

I want to change the location of the /_ah/health request. Is there a way to do this change?

解决方案

So, suppose you have a "health-check serving endpoint" (using webapp2 for definiteness, other frameworks would of course work similarly) in health.py:

class HealthPage(webapp2.RequestHandler):
  def get(self):
    self.response.write('<html><body><p>I\'m fine!</p></body></html>')

and unfortunately you also have routing information hard-coded, say in the same file (rather than more properly reading it from an easily modified and pushed configuration file):

application = webapp2.WSGIApplication([
  ('/howareyou', HealthPage),
])

Now, to serve health checks from that same HealthPage handler, you need to edit your app.yaml to have:

handlers:
- url: /_ah/health
  script: health.application

before any handlers whose url: has wildcards that might "swallow" this one, of course.

Now, since you have a strict, hard-coded routing decision in your application object, you'll have to edit that. This isn't really "editing code" -- it's editing configuration information that you unfortunately decided to embed as strict, hard-coded strings in your code, rather than picking it up from a configuration code.

Either make the in-code routing less strict, maybe all the way down to:

application = webapp2.WSGIApplication([
  ('.*', HealthPage),
])

or if you're committed to using very strict hardcoded routes in your code, you' might choose to add one line...:

application = webapp2.WSGIApplication([
  ('/howareyou', HealthPage),
  ('/_ah/health', HealthPage),
])

Similarly for other routing systems (beyond app.yaml and other configuration-based routing done for you by App Engine itself) of course -- webapp2's routing system is nothing strange, nor anomalous.

Note that none of these edits stop your code from serving the /howareyou URL if it's routed to health.py in other (non-GAE and non-GAE-like) deployments -- they'll serve it just as well as they used to do.

If despite all of this you still demand a "URL rewriting" capability in app.yaml, or similarly powerful features, to deal with health checks while avoiding the need for this kind of tiny workaround, you can of course open a feature request at https://code.google.com/p/googleappengine/issues/list -- I just can't imagine it getting high urgency vs the thousands of open issues there, but, hey!, I've been wrong before:-).

这篇关于如何为托管虚拟机配置Google App Engine运行状况检查端点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆