Convert to play2 project
parent
1c00598253
commit
3b63327632
|
@ -0,0 +1,9 @@
|
|||
package lila.http
|
||||
|
||||
import lila.system.SystemEnv
|
||||
import com.typesafe.config._
|
||||
|
||||
final class HttpEnv(config: Config) {
|
||||
|
||||
lazy val system = SystemEnv(config)
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package controllers
|
||||
|
||||
import lila.http._
|
||||
|
||||
import com.typesafe.config._
|
||||
import play.api._
|
||||
import play.api.mvc._
|
||||
|
||||
object Application extends Controller {
|
||||
|
||||
val env = new HttpEnv(Play.unsafeApplication.configuration.underlying)
|
||||
|
||||
def index = TODO
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
mongo {
|
||||
host = "127.0.0.1"
|
||||
port = 27017
|
||||
dbName = lichess
|
||||
collection {
|
||||
game = game2
|
||||
}
|
||||
}
|
||||
redis {
|
||||
host = localhost
|
||||
port = 6379
|
||||
}
|
||||
|
||||
application.secret="CiebwjgIM9cHQ;I?Xk:sfqDJ;BhIe:jsL?r=?IPF[saf>s^r0]?0grUq4>q?5mP^"
|
||||
|
||||
application.langs="en"
|
||||
|
||||
# Global object class
|
||||
# ~~~~~
|
||||
# Define the Global object class for this application.
|
||||
# Default to Global in the root package.
|
||||
# global=Global
|
||||
|
||||
evolutionplugin=disabled
|
||||
|
||||
# Logger
|
||||
# ~~~~~
|
||||
# You can also configure logback (http://logback.qos.ch/), by providing a logger.xml file in the conf directory .
|
||||
|
||||
# Root logger:
|
||||
logger.root=ERROR
|
||||
|
||||
# Logger used by the framework:
|
||||
logger.play=INFO
|
||||
|
||||
# Logger provided to your application:
|
||||
logger.application=DEBUG
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
# Routes
|
||||
# This file defines all application routes (Higher priority routes first)
|
||||
# ~~~~
|
||||
|
||||
# Home page
|
||||
GET / controllers.Application.index
|
||||
|
||||
# Map static resources from the /public folder to the /assets URL path
|
||||
GET /assets/*file controllers.Assets.at(path="/public", file)
|
|
@ -1,23 +0,0 @@
|
|||
package lila.http
|
||||
|
||||
object Cli {
|
||||
|
||||
def main(args: Array[String]) {
|
||||
|
||||
args.headOption flatMap makeEnv map { env ⇒
|
||||
args.tail.toList match {
|
||||
case "fixtures" :: Nil ⇒ fixtures(env)
|
||||
case _ => sys error "Invalid command"
|
||||
}
|
||||
} err "Invalid environment"
|
||||
}
|
||||
|
||||
def makeEnv(name: String) = name match {
|
||||
case "test" ⇒ Env.test some
|
||||
case _ ⇒ none
|
||||
}
|
||||
|
||||
def fixtures(env: Env) {
|
||||
println("Load %s fixtures" format env.name)
|
||||
}
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
package lila.http
|
||||
|
||||
import repo._
|
||||
import com.mongodb.casbah.MongoConnection
|
||||
import com.mongodb.casbah.commons.conversions.scala._
|
||||
|
||||
final class Env(configuration: Env.Settings, val name: String = "default") {
|
||||
|
||||
lazy val gameRepo = new GameRepo(mongodb("game2"))
|
||||
|
||||
private lazy val mongodb = MongoConnection(
|
||||
get[String]("mongo.host"),
|
||||
get[Int]("mongo.port")
|
||||
)(get[String]("mongo.dbname"))
|
||||
|
||||
private def get[A](key: String) = configuration(key).asInstanceOf[A]
|
||||
|
||||
def ~(settings: Env.Settings) = new Env(
|
||||
configuration ++ settings,
|
||||
name
|
||||
)
|
||||
}
|
||||
|
||||
object Env {
|
||||
|
||||
type Settings = Map[String, Any]
|
||||
|
||||
private val defaults = Map(
|
||||
"mongo.host" -> "127.0.0.1",
|
||||
"mongo.port" -> 27017,
|
||||
"mongo.dbname" -> "lichess"
|
||||
)
|
||||
|
||||
def test = new Env(defaults ++ Map(
|
||||
"mongo.dbname" -> "lichess_test"
|
||||
), "test")
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
import sbt._
|
||||
import Keys._
|
||||
import PlayProject._
|
||||
|
||||
trait Resolvers {
|
||||
val codahale = "repo.codahale.com" at "http://repo.codahale.com/"
|
||||
|
@ -41,44 +42,43 @@ object ApplicationBuild extends Build with Resolvers with Dependencies {
|
|||
scalacOptions := Seq("-deprecation", "-unchecked")
|
||||
)
|
||||
|
||||
lazy val chess = Project("chess", file("chess"), settings = buildSettings).settings(
|
||||
libraryDependencies ++= Seq(hasher)
|
||||
)
|
||||
val lila = PlayProject("lila", mainLang = SCALA, settings = buildSettings).settings(
|
||||
libraryDependencies ++= Seq(scalaz, slf4j)
|
||||
) dependsOn (system)
|
||||
|
||||
lazy val system = Project("system", file("system"), settings = buildSettings).settings(
|
||||
libraryDependencies ++= Seq(scalaz, config, redis, json, casbah, salat, slf4j)
|
||||
) dependsOn (chess)
|
||||
|
||||
lazy val http = Project("http", file("http"), settings = buildSettings).settings(
|
||||
libraryDependencies ++= Seq(scalaz, slf4j),
|
||||
resolvers := Seq(typesafe)
|
||||
) dependsOn (system)
|
||||
lazy val chess = Project("chess", file("chess"), settings = buildSettings).settings(
|
||||
libraryDependencies ++= Seq(hasher)
|
||||
)
|
||||
|
||||
lazy val benchmark = Project("benchmark", file("benchmark"), settings = buildSettings).settings(
|
||||
fork in run := true,
|
||||
libraryDependencies ++= Seq(instrumenter, gson),
|
||||
// we need to add the runtime classpath as a "-cp" argument
|
||||
// to the `javaOptions in run`, otherwise caliper
|
||||
// will not see the right classpath and die with a ConfigurationException
|
||||
// unfortunately `javaOptions` is a SettingsKey and
|
||||
// `fullClasspath in Runtime` is a TaskKey, so we need to
|
||||
// jump through these hoops here in order to
|
||||
// feed the result of the latter into the former
|
||||
onLoad in Global ~= { previous ⇒
|
||||
state ⇒
|
||||
previous {
|
||||
state get key match {
|
||||
case None ⇒
|
||||
// get the runtime classpath, turn into a colon-delimited string
|
||||
val classPath = Project.runTask(fullClasspath in Runtime, state).get._2.toEither.right.get.files.mkString(":")
|
||||
// return a state with javaOptionsPatched = true and javaOptions set correctly
|
||||
Project.extract(state).append(Seq(javaOptions in run ++= Seq("-cp", classPath)), state.put(key, true))
|
||||
case Some(_) ⇒ state // the javaOptions are already patched
|
||||
}
|
||||
}
|
||||
}
|
||||
) dependsOn (chess, system)
|
||||
//lazy val benchmark = Project("benchmark", file("benchmark"), settings = buildSettings).settings(
|
||||
//fork in run := true,
|
||||
//libraryDependencies ++= Seq(instrumenter, gson),
|
||||
//// we need to add the runtime classpath as a "-cp" argument
|
||||
//// to the `javaOptions in run`, otherwise caliper
|
||||
//// will not see the right classpath and die with a ConfigurationException
|
||||
//// unfortunately `javaOptions` is a SettingsKey and
|
||||
//// `fullClasspath in Runtime` is a TaskKey, so we need to
|
||||
//// jump through these hoops here in order to
|
||||
//// feed the result of the latter into the former
|
||||
//onLoad in Global ~= { previous ⇒
|
||||
//state ⇒
|
||||
//previous {
|
||||
//state get key match {
|
||||
//case None ⇒
|
||||
//// get the runtime classpath, turn into a colon-delimited string
|
||||
//val classPath = Project.runTask(fullClasspath in Runtime, state).get._2.toEither.right.get.files.mkString(":")
|
||||
//// return a state with javaOptionsPatched = true and javaOptions set correctly
|
||||
//Project.extract(state).append(Seq(javaOptions in run ++= Seq("-cp", classPath)), state.put(key, true))
|
||||
//case Some(_) ⇒ state // the javaOptions are already patched
|
||||
//}
|
||||
//}
|
||||
//}
|
||||
//) dependsOn (chess, system)
|
||||
|
||||
// attribute key to prevent circular onLoad hook (for benchmark)
|
||||
val key = AttributeKey[Boolean]("javaOptionsPatched")
|
||||
//// attribute key to prevent circular onLoad hook (for benchmark)
|
||||
//val key = AttributeKey[Boolean]("javaOptionsPatched")
|
||||
}
|
||||
|
|
|
@ -1 +1,8 @@
|
|||
// Comment to get more information during initialization
|
||||
logLevel := Level.Warn
|
||||
|
||||
// The Typesafe repository
|
||||
resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"
|
||||
|
||||
// Use the Play sbt plugin for Play projects
|
||||
addSbtPlugin("play" % "sbt-plugin" % "2.0")
|
|
@ -35,6 +35,10 @@ object SystemEnv extends EnvBuilder {
|
|||
def apply(overrides: String = "") = new SystemEnv {
|
||||
val config = makeConfig(overrides, "/home/thib/lila/lila.conf")
|
||||
}
|
||||
|
||||
def apply(c: Config) = new SystemEnv {
|
||||
val config = c
|
||||
}
|
||||
}
|
||||
|
||||
trait EnvBuilder {
|
||||
|
|
Loading…
Reference in New Issue