./bin/jetty.sh 停止时未调用环销毁功能?
ring destroy function not called on ./bin/jetty.sh stop?
我有一个具有以下配置的环形项目
:ring {:port 3000
:handler myservice.core/standalone-app
:init myservice.core/init!
:destroy myservice.core/destroy!}
这些功能很简单,就是记录日志。他们有一天可能会做得更多。
(defn init! [] (log/info "init!"))
(defn destroy! [] (log/info "destroy!"))
我用 uberwar 打造了这个孩子。 lein ring uberwar myservice.war
码头日志显示 init!登录启动,但销毁!无处可见日志记录。甚至被称为销毁吗?我怎么知道?
原来我需要配置日志框架。在没有日志记录配置的情况下允许 init 似乎很奇怪!登录到标准输出,但销毁!无处可去。
我将 logback 添加到我的 project.clj 作为依赖项并构建了一个骨架 logback.xml 配置文件,中提琴!
2015-12-23 11:42:53.192:INFO:oejs.Server:jetty-8.1.16.v20140903
2015-12-23 11:42:53.208:INFO:oejdp.ScanningAppProvider:Deployment monitor /Users/robert.kuhar/work/jetty-distribution-8.1.16.v20140903/webapps at interval 1
...
2015-12-23 11:42:53.598:INFO:oejd.DeploymentManager:Deployable added: /Users/robert.kuhar/work/jetty-distribution-8.1.16.v20140903/webapps/myservice.war
2015-12-23 11:42:53.600:INFO:oejw.WebInfConfiguration:Extract jar:file:/Users/robert.kuhar/work/jetty-distribution-8.1.16.v20140903/webapps/myservice.war!/ to /private/var/folders/1g/fnytl2x93sx6hp2f1rsf4h1r5xtqv_/T/jetty-0.0.0.0-8080-myservice.war-_myservice-any-/webapp
2015-12-23T11:42:58.851 INFO m.core - app
2015-12-23T11:42:58.856 INFO m.core - standalone-app
println init!
2015-12-23T11:42:58.857 INFO m.core - init!
...
2015-12-23 11:42:59.146:INFO:oejs.AbstractConnector:Started SelectChannelConnector@0.0.0.0:8080
...
2015-12-23 11:45:48.432:INFO:oejs.Server:Graceful shutdown SelectChannelConnector@0.0.0.0:8080
...
2015-12-23 11:45:48.434:INFO:oejs.Server:Graceful shutdown o.e.j.w.WebAppContext{/myservice,file:/private/var/folders/1g/fnytl2x93sx6hp2f1rsf4h1r5xtqv_/T/jetty-0.0.0.0-8080-myservice.war-_myservice-any-/webapp/},/Users/robert.kuhar/work/jetty-distribution-8.1.16.v20140903/webapps/myservice.war
println destroy!
2015-12-23T11:45:49.553 INFO m.core - destroy!
...
2015-12-23 11:45:49.553:INFO:oejsh.ContextHandler:stopped o.e.j.w.WebAppContext{/myservice,file:/private/var/folders/1g/fnytl2x93sx6hp2f1rsf4h1r5xtqv_/T/jetty-0.0.0.0-8080-myservice.war-_myservice-any-/webapp/},/Users/robert.kuhar/work/jetty-distribution-8.1.16.v20140903/webapps/myservice.war
...
我有一个具有以下配置的环形项目
:ring {:port 3000
:handler myservice.core/standalone-app
:init myservice.core/init!
:destroy myservice.core/destroy!}
这些功能很简单,就是记录日志。他们有一天可能会做得更多。
(defn init! [] (log/info "init!"))
(defn destroy! [] (log/info "destroy!"))
我用 uberwar 打造了这个孩子。 lein ring uberwar myservice.war
码头日志显示 init!登录启动,但销毁!无处可见日志记录。甚至被称为销毁吗?我怎么知道?
原来我需要配置日志框架。在没有日志记录配置的情况下允许 init 似乎很奇怪!登录到标准输出,但销毁!无处可去。
我将 logback 添加到我的 project.clj 作为依赖项并构建了一个骨架 logback.xml 配置文件,中提琴!
2015-12-23 11:42:53.192:INFO:oejs.Server:jetty-8.1.16.v20140903
2015-12-23 11:42:53.208:INFO:oejdp.ScanningAppProvider:Deployment monitor /Users/robert.kuhar/work/jetty-distribution-8.1.16.v20140903/webapps at interval 1
...
2015-12-23 11:42:53.598:INFO:oejd.DeploymentManager:Deployable added: /Users/robert.kuhar/work/jetty-distribution-8.1.16.v20140903/webapps/myservice.war
2015-12-23 11:42:53.600:INFO:oejw.WebInfConfiguration:Extract jar:file:/Users/robert.kuhar/work/jetty-distribution-8.1.16.v20140903/webapps/myservice.war!/ to /private/var/folders/1g/fnytl2x93sx6hp2f1rsf4h1r5xtqv_/T/jetty-0.0.0.0-8080-myservice.war-_myservice-any-/webapp
2015-12-23T11:42:58.851 INFO m.core - app
2015-12-23T11:42:58.856 INFO m.core - standalone-app
println init!
2015-12-23T11:42:58.857 INFO m.core - init!
...
2015-12-23 11:42:59.146:INFO:oejs.AbstractConnector:Started SelectChannelConnector@0.0.0.0:8080
...
2015-12-23 11:45:48.432:INFO:oejs.Server:Graceful shutdown SelectChannelConnector@0.0.0.0:8080
...
2015-12-23 11:45:48.434:INFO:oejs.Server:Graceful shutdown o.e.j.w.WebAppContext{/myservice,file:/private/var/folders/1g/fnytl2x93sx6hp2f1rsf4h1r5xtqv_/T/jetty-0.0.0.0-8080-myservice.war-_myservice-any-/webapp/},/Users/robert.kuhar/work/jetty-distribution-8.1.16.v20140903/webapps/myservice.war
println destroy!
2015-12-23T11:45:49.553 INFO m.core - destroy!
...
2015-12-23 11:45:49.553:INFO:oejsh.ContextHandler:stopped o.e.j.w.WebAppContext{/myservice,file:/private/var/folders/1g/fnytl2x93sx6hp2f1rsf4h1r5xtqv_/T/jetty-0.0.0.0-8080-myservice.war-_myservice-any-/webapp/},/Users/robert.kuhar/work/jetty-distribution-8.1.16.v20140903/webapps/myservice.war
...