grails app在一些空闲时间后终止 - 什么触发意外关闭?

时间:2014-12-16 10:03:18

标签: grails shutdown

我有一个Grails 2.4.3应用程序供我公司内部使用。 问题是,在我运行它(grails dev run-app)一段时间后,它会在没有事先通知的情况下终止收听:

INFO  [Thread-3]: Pausing ProtocolHandler ["http-bio-8080"]
INFO  [Thread-3]: Stopping service Tomcat
### Shutting down.
INFO  [Thread-3]: Stopping ProtocolHandler ["http-bio-8080"]
INFO  [Thread-3]: Destroying ProtocolHandler ["http-bio-8080"]  

(第3行来自我的BootStrap.groovy中的destroy()方法)

对于数据源连接,池化连接有keepalive strategies。我也希望grails应用程序能够保持在线状态。

如何调查导致服务器停止收听的原因? 这是一个常见问题,可以通过配置解决吗?

编辑:

根记录器在DEBUG级别显示以下内容:

DEBUG [http-bio-8080-exec-4]: Counting down[http-bio-8080-exec-4] latch=2
DEBUG [http-bio-8080-exec-1]: Error parsing HTTP request header
java.net.SocketTimeoutException: Read timed out
    at java.net.SocketInputStream.socketRead0(Native Method)
...
DEBUG [http-bio-8080-exec-1]: Socket: [org.apache.tomcat.util.net.SocketWrapper@5c0b659a:Socket[addr=/0:0:0:0:0:0:0:1,port=58705,localport=8080]], Status in: [OPEN_READ], State out: [CLOSED]
DEBUG [http-bio-8080-exec-1]: Counting down[http-bio-8080-exec-1] latch=1
DEBUG [ContainerBackgroundProcessor[StandardEngine[Tomcat]]]: Start expire sessions StandardManager at 1421320212649 sessioncount 0
DEBUG [ContainerBackgroundProcessor[StandardEngine[Tomcat]]]: End expire sessions StandardManager processingTime 0 expired sessions: 0
DEBUG [ContainerBackgroundProcessor[StandardEngine[Tomcat]]]: Start expire sessions StandardManager at 1421320272661 sessioncount 0
DEBUG [ContainerBackgroundProcessor[StandardEngine[Tomcat]]]: End expire sessions StandardManager processingTime 0 expired sessions: 0
DEBUG [ContainerBackgroundProcessor[StandardEngine[Tomcat]]]: Start expire sessions StandardManager at 1421320332673 sessioncount 0
DEBUG [ContainerBackgroundProcessor[StandardEngine[Tomcat]]]: End expire sessions StandardManager processingTime 0 expired sessions: 0
DEBUG [http-bio-8080-Acceptor-0]: Counting up[http-bio-8080-Acceptor-0] latch=1
DEBUG [http-bio-8080-exec-6]: Error parsing HTTP request header
java.net.SocketException: Connection reset
    at java.net.SocketInputStream.read(SocketInputStream.java:196)
    at java.net.SocketInputStream.read(SocketInputStream.java:122)
    at org.apache.coyote.http11.InternalInputBuffer.fill(InternalInputBuffer.java:519)
...
DEBUG [http-bio-8080-exec-6]: Socket: [org.apache.tomcat.util.net.SocketWrapper@674b5757:Socket[addr=/10.41.2.116,port=46215,localport=8080]], Status in: [OPEN_READ], State out: [CLOSED]
DEBUG [http-bio-8080-exec-6]: Counting down[http-bio-8080-exec-6] latch=1
DEBUG [Thread-3]: Setting state for [StandardServer[-1]] to [STOPPING_PREP]
DEBUG [Thread-3]: Setting state for [StandardServer[-1]] to [STOPPING]
DEBUG [Thread-3]: Setting state for [StandardService[Tomcat]] to [STOPPING_PREP]
INFO  [Thread-3]: Pausing ProtocolHandler ["http-bio-8080"]
DEBUG [Thread-3]: About to unlock socket for:localhost/127.0.0.1:8080
DEBUG [Thread-3]: Socket unlock completed for:localhost/127.0.0.1:8080
DEBUG [http-bio-8080-Acceptor-0]: Counting down[http-bio-8080-Acceptor-0] latch=0
INFO  [Thread-3]: Stopping service Tomcat
DEBUG [Thread-3]: Setting state for [StandardService[Tomcat]] to [STOPPING]
DEBUG [Thread-3]: Setting state for [StandardEngine[Tomcat]] to [STOPPING_PREP]
DEBUG [Thread-3]: Setting state for [StandardEngine[Tomcat]] to [STOPPING]
DEBUG [Thread-3]: Setting state for [Pipeline[StandardEngine[Tomcat]]] to [STOPPING_PREP]
DEBUG [Thread-3]: Setting state for [Pipeline[StandardEngine[Tomcat]]] to [STOPPING]
DEBUG [Thread-3]: Setting state for [org.apache.catalina.core.StandardEngineValve[Tomcat]] to [STOPPING_PREP]
DEBUG [Thread-3]: Setting state for [org.apache.catalina.core.StandardEngineValve[Tomcat]] to [STOPPING]
DEBUG [Thread-3]: Setting state for [org.apache.catalina.core.StandardEngineValve[Tomcat]] to [STOPPED]
DEBUG [Thread-3]: Setting state for [Pipeline[StandardEngine[Tomcat]]] to [STOPPED]
DEBUG [Tomcat-startStop-2]: Setting state for [StandardEngine[Tomcat].StandardHost[localhost]] to [STOPPING_PREP]
DEBUG [Tomcat-startStop-2]: Unregister host [localhost] at domain [null] for connector [Connector[HTTP/1.1-8080]]
DEBUG [Tomcat-startStop-2]: Setting state for [StandardEngine[Tomcat].StandardHost[localhost]] to [STOPPING]
DEBUG [Tomcat-startStop-2]: Setting state for [Pipeline[StandardEngine[Tomcat].StandardHost[localhost]]] to [STOPPING_PREP]
DEBUG [Tomcat-startStop-2]: Setting state for [Pipeline[StandardEngine[Tomcat].StandardHost[localhost]]] to [STOPPING]
DEBUG [Tomcat-startStop-2]: Setting state for [org.apache.catalina.valves.ErrorReportValve[localhost]] to [STOPPING_PREP]
DEBUG [Tomcat-startStop-2]: Setting state for [org.apache.catalina.valves.ErrorReportValve[localhost]] to [STOPPING]
DEBUG [Tomcat-startStop-2]: Setting state for [org.apache.catalina.valves.ErrorReportValve[localhost]] to [STOPPED]
DEBUG [Tomcat-startStop-2]: Setting state for [org.apache.catalina.core.StandardHostValve[localhost]] to [STOPPING_PREP]
DEBUG [Tomcat-startStop-2]: Setting state for [org.apache.catalina.core.StandardHostValve[localhost]] to [STOPPING]
DEBUG [Tomcat-startStop-2]: Setting state for [org.apache.catalina.core.StandardHostValve[localhost]] to [STOPPED]
DEBUG [Tomcat-startStop-2]: Setting state for [Pipeline[StandardEngine[Tomcat].StandardHost[localhost]]] to [STOPPED]
DEBUG [localhost-startStop-2]: Setting state for [StandardEngine[Tomcat].StandardHost[localhost].StandardContext[/workspent]] to [STOPPING_PREP]
DEBUG [localhost-startStop-2]: Unregister Context [/workspent] for connector [Connector[HTTP/1.1-8080]]
DEBUG [localhost-startStop-2]: Setting state for [StandardEngine[Tomcat].StandardHost[localhost].StandardContext[/workspent]] to [STOPPING]
DEBUG [localhost-startStop-2]: Setting state for [StandardEngine[Tomcat].StandardHost[localhost].StandardContext[/workspent].StandardWrapper[grails-errorhandler]] to [STOPPING_PREP]
DEBUG [localhost-startStop-2]: Unregister Wrapper [grails-errorhandler] in Context [/workspent] for connector [Connector[HTTP/1.1-8080]]
DEBUG [localhost-startStop-2]: Setting state for [StandardEngine[Tomcat].StandardHost[localhost].StandardContext[/workspent].StandardWrapper[grails-errorhandler]] to [STOPPING]
DEBUG [localhost-startStop-2]: Setting state for [Pipeline[StandardEngine[Tomcat].StandardHost[localhost].StandardContext[/workspent].StandardWrapper[grails-errorhandler]]] to [STOPPING_PREP]
DEBUG [localhost-startStop-2]: Setting state for [Pipeline[StandardEngine[Tomcat].StandardHost[localhost].StandardContext[/workspent].StandardWrapper[grails-errorhandler]]] to [STOPPING]
DEBUG [localhost-startStop-2]: Setting state for [org.apache.catalina.core.StandardWrapperValve[grails-errorhandler]] to [STOPPING_PREP]
DEBUG [localhost-startStop-2]: Setting state for [org.apache.catalina.core.StandardWrapperValve[grails-errorhandler]] to [STOPPING]
DEBUG [localhost-startStop-2]: Setting state for [org.apache.catalina.core.StandardWrapperValve[grails-errorhandler]] to [STOPPED]
DEBUG [localhost-startStop-2]: Setting state for [Pipeline[StandardEngine[Tomcat].StandardHost[localhost].StandardContext[/workspent].StandardWrapper[grails-errorhandler]]] to [STOPPED]
DEBUG [localhost-startStop-2]: Setting state for [StandardEngine[Tomcat].StandardHost[localhost].StandardContext[/workspent].StandardWrapper[grails-errorhandler]] to [STOPPED]
DEBUG [localhost-startStop-2]: Setting state for [StandardEngine[Tomcat].StandardHost[localhost].StandardContext[/workspent].StandardWrapper[grails]] to [STOPPING_PREP]
DEBUG [localhost-startStop-2]: Unregister Wrapper [grails] in Context [/workspent] for connector [Connector[HTTP/1.1-8080]]
INFO  [localhost-startStop-2]: ### Shutting down. Current time is 2015-01-15T12:12:39.009+01:00
INFO  [localhost-startStop-2]: Destroying Spring FrameworkServlet 'grails'

1 个答案:

答案 0 :(得分:1)

查看您的stacktrace.log文件,可能会出现一些错误。
正如docs所说:

  

当出现异常时,可能会有很多噪音   来自Java和Groovy内部的堆栈跟踪。 Grails过滤这些   通常是不相关的细节,并限制非核心的痕迹   Grails / Groovy类包。

     

发生这种情况时,完整跟踪始终记录到StackTrace   logger,默认情况下将其输出写入名为的文件   stacktrace.log

如果您不知道文件的位置,可以通过log4j进行配置:http://grails.org/doc/latest/guide/conf.html

Config.groovy

error stdout: "StackTrace"
log4j = {
    appenders {
        rollingFile name: "stacktrace", maxFileSize: 1024,
                    file: "/var/tmp/logs/myApp-stacktrace.log"
    }
}