简体   繁体   English

控制Finagle中的/ health端点

[英]Take control over /health endpoint in finagle

I'm trying to override health endpoint. 我正在尝试覆盖运行状况终结点。 I need to make it return something else then 'OK'. 我需要使其返回其他内容,然后单击“确定”。 As described in docs, I should use Lifecycle.Warmup trait. 如文档中所述,我应该使用Lifecycle.Warmup特征。 Neither 也不

HttpMuxer.addHandler(Route("/health", new ReplyHandler("not OK\n"))) 

nor overriding method doesn't helped yet. 否决方法仍无济于事。

This code below, doesn't help either. 下面的这段代码也无济于事。

HttpMuxer.addHandler(
      Route(
        pattern = "/health",
        handler = new ReplyHandler("not OK\n"),
        index = Some(RouteIndex(
          alias = "Health",
          group = group))))

What should I do to change this message? 我该怎么做才能更改此消息?

UPD: One more approach which should work but it doesn't UPD:另一种方法应该有效,但无效

premain {
    addAdminRoute(
      AdminHttpServer
        .Route("/health1",
          handler = service,
          "Service Health",
          Some("Misc"),
          false, Method.Get)
    )
  }
  val service = new Service[Request, Response] {
    def apply(request: Request) = {
      val response = Response(request.version, Status.Ok)
      response.contentString = "test" + "\n"
      com.twitter.util.Future.value(response)
    }
  }

I debug, I see it's added to Muxer, I see it appears in logs as well. 我调试,我看到它已添加到Muxer,我也看到它也出现在日志中。 Have no idea why it doesn't work 不知道为什么它不起作用

日志

That looks like it should work. 看起来应该可以。 You should double check that the url you're hitting is $ADMIN_HOST:$ADMIN_PORT/health and not $ADMIN_HOST:$ADMIN_PORT/admin/health. 您应该仔细检查,您要命中的网址是$ ADMIN_HOST:$ ADMIN_PORT / health,而不是$ ADMIN_HOST:$ ADMIN_PORT / admin / health。

Sounds a bit fantastic, but if I place this code before main, instead of premain - it works. 听起来有些不可思议,但是如果我将这段代码放在main之前,而不是premain上,它将起作用。

HttpMuxer.addHandler(
    Route(
      pattern = "/health",
      handler = new ReplyHandler("not OK\n"),
      index = Some(RouteIndex(alias = "Health", group = group))
    )
  )

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM