【发布时间】:2014-01-29 19:05:03
【问题描述】:
在带有 scala 2.10.3 的 MacOS X 10.8.4 上使用 Play Framework 2.2.1,我有以下代码:
package controllers
import play.api._
object Global extends GlobalSettings {
override def onStart(app: Application) {
Logger.info("Application has started")
}
override def onStop(app: Application) {
Logger.info("Application shutdown...")
Store.shutdown()
Logger.info("Shutdown complete")
}
}
当我使用 play run 的开发模式时,我得到以下信息:
[info] Loading project definition from /Users/jon/code/test/project
[info] Set current project to critter (in build file:/Users/jon/code/test/)
--- (Running the application from SBT, auto-reloading is enabled) ---
[info] play - Listening for HTTP on /0:0:0:0:0:0:0:0%0:9000
(Server started, use Ctrl+D to stop and go back to the console...)
[info] Compiling 1 Scala source to /Users/jon/code/test/target/scala-2.10/classes...
[info] play - Application started (Dev)
[info] Compiling 1 Scala source to /Users/jon/code/test/target/scala-2.10/classes...
--- (RELOAD) ---
[info] play - Application started (Dev)
正如您在此处看到的,我触发了一个请求,该请求导致应用程序被编译,然后请求被处理。我在源文件中插入了一个换行符并再次发出请求,以触发重新加载。 我没有收到有关应用程序关闭的消息。
我使用的是嵌入式数据库,所以我需要优雅地关闭它。如果我不能赶上关机,我不能那样做。是我做错了什么,还是 Play 和自动重新加载的错误?
谢谢!
【问题讨论】:
标签: scala playframework playframework-2.2