由monit监控的弹簧启动应用程序中的管道异常断开

Hug*_*ège 6 spring-mvc monit spring-boot

我有一个由monit监控的spring-boot应用程序.Monit只是检查/ health端点弹簧是否暴露.

基本上,monit注册了以下检查:

check host hopsearch_connection with address 127.0.0.1
 if failed url http://127.0.0.1:8089/health with timeout 15 seconds then alert

check host hopsearch_health with address 127.0.0.1
  if failed url http://127.0.0.1:8089/health
   and content != 'DOWN'
   with timeout 60 seconds
  then alert
Run Code Online (Sandbox Code Playgroud)

并且Web应用程序返回类似的内容:

{"status":"UP","jestHealth":{"status":"UP","lastQuerySuccess":true},"diskSpace":{"status":"UP","free":14439550976,"threshold":10485760},"rabbit":{"status":"UP","version":"3.3.2"},"redis":{"status":"UP","version":"3.0.0"},"mongo":{"status":"UP","version":"2.6.1"}}
Run Code Online (Sandbox Code Playgroud)

在这个spring应用程序中,我有一个通用的@ExceptionHandler来记录所有意外错误并显示错误页面:

@ExceptionHandler(Exception.class)
@ResponseStatus(value = HttpStatus.INTERNAL_SERVER_ERROR)
public String handleDefaultError(Exception ex, HttpServletRequest httpRequest) {
    logException(httpRequest, ex);

    return "error";
}
Run Code Online (Sandbox Code Playgroud)

这个@ExceptionHandler记录来自monit的每个调用:

<11>May  1 13:20:39 IP 13:20:39.339 t=http-nio-8089-exec-3 l=ERROR c=c.h.s.w.c.ErrorManager m=Error 500 
----------------------------------------------------------------
Request Path=http://127.0.0.1:8089/health
Method=GET
----------------------------------------------------------------
Header :
----------------------------------------------------------------
host = 127.0.0.1:8089
accept = */*
connection = close
user-agent = monit/5.4
----------------------------------------------------------------
<11>May  1 13:20:39 IP 13:20:39.340 t=http-nio-8089-  exec-3 l=ERROR c=c.h.s.w.c.ErrorManager m=Unexpected error :   java.io.IOException: Broken pipe
at sun.nio.ch.FileDispatcherImpl.write0(Native Method) ~[na:1.8.0_25]
at sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:47) ~[na:1.8.0_25]
at sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:93) ~[na:1.8.0_25]
at sun.nio.ch.IOUtil.write(IOUtil.java:65) ~[na:1.8.0_25]
Run Code Online (Sandbox Code Playgroud)

从monit的角度来看,一切都很好,检查工作.从我的角度来看,该应用程序可行.但是我在日志中丢弃了很多错误.

我没有成功使用curl在我的工作站上重现.此异常仅发生在具有monit的服务器上.

是否可以忽略基于ExceptionHandler中特定用户代理的错误?(如何 ?)

这不是最好的解决方案,但我没有看到任何其他方式.

有什么想法吗?