Move HttpEnv to Global object and prepare for actors

pull/1/merge
Thibault Duplessis 2012-03-18 23:39:30 +01:00
parent 7e65833420
commit 860b275c50
6 changed files with 20 additions and 21 deletions

View File

@ -4,8 +4,18 @@ import play.api._
import play.api.mvc._
import play.api.mvc.Results._
import lila.system.SystemEnv
object Global extends GlobalSettings {
private[this] var systemEnv: SystemEnv = _
def env = Option(systemEnv) err "The environment is not ready"
override def onStart(app: Application) {
systemEnv = new SystemEnv(app.configuration.underlying)
}
override def onHandlerNotFound(request: RequestHeader): Result = {
NotFound("Not found " + request)
}

View File

@ -1,12 +0,0 @@
package lila.http
import lila.system.SystemEnv
import play.api.Play
object HttpEnv {
lazy val static = new SystemEnv {
protected val config = Play.unsafeApplication.configuration.underlying
}
}

View File

@ -13,7 +13,7 @@ import scalaz.effects.IO
trait LilaController extends Controller with ContentTypes {
lazy val env = HttpEnv.static
lazy val env = Global.env
def JsonOk(map: Map[String, Any]) = Ok(Json generate map) as JSON

View File

@ -26,6 +26,10 @@ crafty {
book_path = "/usr/share/crafty"
}
akka {
debug.receive = on
}
application.secret="CiebwjgIM9cHQ;I?Xk:sfqDJ;BhIe:jsL?r=?IPF[saf>s^r0]?0grUq4>q?5mP^"
application.langs="en"

View File

@ -69,6 +69,5 @@ final class Syncer(
wait(max(1, duration / sleep))
}
//private val failMap = Map("failMap" -> true)
private val failMap = Map("fuck" -> true)
private val failMap = Map("reload" -> true)
}

View File

@ -7,9 +7,7 @@ import db._
import ai._
import memo._
trait SystemEnv {
protected val config: Config
final class SystemEnv(config: Config) {
def server = new Server(
repo = gameRepo,
@ -63,9 +61,9 @@ trait SystemEnv {
object SystemEnv extends EnvBuilder {
def apply(overrides: String = "") = new SystemEnv {
val config = makeConfig(overrides, "/home/thib/lila/conf/application.conf")
}
def apply(overrides: String = "") = new SystemEnv(
makeConfig(overrides, "/home/thib/lila/conf/application.conf")
)
}
trait EnvBuilder {