disable scheduling for short runs
This commit is contained in:
parent
ae4d52b4aa
commit
224daa6ea0
|
@ -3,7 +3,7 @@ package lila.app
|
|||
import akka.actor._
|
||||
import com.typesafe.config.Config
|
||||
|
||||
final class Env(config: Config, system: ActorSystem) {
|
||||
final class Env(config: Config, system: ActorSystem, isServer: Boolean) {
|
||||
|
||||
val CliUsername = config getString "cli.username"
|
||||
|
||||
|
@ -20,7 +20,7 @@ final class Env(config: Config, system: ActorSystem) {
|
|||
domain = Env.api.Net.Domain
|
||||
)), name = RouterName)
|
||||
|
||||
if (ModulePreload) {
|
||||
if (ModulePreload && isServer) {
|
||||
loginfo("Preloading modules")
|
||||
(Env.site, Env.game, Env.setup, Env.game, Env.gameSearch, Env.team,
|
||||
Env.teamSearch, Env.forumSearch, Env.message)
|
||||
|
@ -34,7 +34,8 @@ object Env {
|
|||
|
||||
lazy val current = "[boot] app" describes new Env(
|
||||
config = lila.common.PlayApp.loadConfig,
|
||||
system = lila.common.PlayApp.system)
|
||||
system = lila.common.PlayApp.system,
|
||||
isServer = lila.common.PlayApp.isServer)
|
||||
|
||||
def api = lila.api.Env.current
|
||||
def db = lila.db.Env.current
|
||||
|
|
|
@ -33,5 +33,5 @@ object Environment
|
|||
def netDomain = apiEnv.Net.Domain
|
||||
def netBaseUrl = apiEnv.Net.BaseUrl
|
||||
|
||||
def isDev = apiEnv.isDev
|
||||
def isProd = apiEnv.isProd
|
||||
}
|
||||
|
|
|
@ -129,7 +129,7 @@ signedJs: Option[String] = None)(body: Html)(implicit ctx: Context)
|
|||
</div>
|
||||
</div>
|
||||
@jsTag("deps.min.js")
|
||||
@signedJs.fold(isDev.fold(jsTag("big.js"), jsTagC("big.js")))(jsAt)
|
||||
@signedJs.fold(isProd.fold(jsTagC("big.js"), jsTag("big.js")))(jsAt)
|
||||
@moreJs
|
||||
@if(lang.language != "en") {
|
||||
<script src="@routes.Assets.at("trans/" + lang.language + ".js")?v=@assetVersion"></script>
|
||||
|
|
|
@ -5,7 +5,7 @@ import lila.common.PimpedConfig._
|
|||
import akka.actor.{ ActorRef, ActorSystem }
|
||||
import com.typesafe.config.Config
|
||||
|
||||
final class Env(config: Config, system: ActorSystem, isDev: Boolean) {
|
||||
final class Env(config: Config, system: ActorSystem, schedule: Boolean) {
|
||||
|
||||
private val settings = new {
|
||||
val EngineName = config getString "engine"
|
||||
|
@ -33,14 +33,14 @@ final class Env(config: Config, system: ActorSystem, isDev: Boolean) {
|
|||
|
||||
def isServer = IsServer
|
||||
|
||||
{
|
||||
if (schedule) {
|
||||
val scheduler = new lila.common.Scheduler(system)
|
||||
import scala.concurrent.duration._
|
||||
|
||||
scheduler.effect(10 seconds, "ai: diagnose") {
|
||||
clientDiagnose
|
||||
}
|
||||
if (!isDev) clientDiagnose
|
||||
clientDiagnose
|
||||
}
|
||||
|
||||
private lazy val stockfishAi = new stockfish.Ai(
|
||||
|
@ -79,5 +79,5 @@ object Env {
|
|||
lazy val current = "[boot] ai" describes new Env(
|
||||
config = lila.common.PlayApp loadConfig "ai",
|
||||
system = lila.common.PlayApp.system,
|
||||
isDev = lila.common.PlayApp.isDev)
|
||||
schedule = lila.common.PlayApp.isServer)
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import play.api.Application
|
|||
final class Env(
|
||||
application: Application,
|
||||
config: Config,
|
||||
val isDev: Boolean) {
|
||||
val isProd: Boolean) {
|
||||
|
||||
val CliUsername = config getString "cli.username"
|
||||
|
||||
|
@ -26,5 +26,5 @@ object Env {
|
|||
lazy val current = "[boot] api" describes new Env(
|
||||
application = play.api.Play.current,
|
||||
config = lila.common.PlayApp.loadConfig,
|
||||
isDev = lila.common.PlayApp.isDev)
|
||||
isProd = lila.common.PlayApp.isProd)
|
||||
}
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
package lila.bookmark
|
||||
|
||||
import lila.db.Implicits._
|
||||
import lila.db.DbApi._
|
||||
import lila.db.api._
|
||||
import lila.db.test.WithDb
|
||||
import tube.bookmarkTube
|
||||
|
||||
import org.specs2.mutable.Specification
|
||||
|
||||
|
@ -19,9 +20,8 @@ final class RepoTest extends Specification {
|
|||
|
||||
import makeTimeout.large
|
||||
|
||||
def cleanRepo = Env.current.bookmarkRepo ~ { repo ⇒
|
||||
(repo.remove(select.all) /* >> repo.insert(bookmark) */ ).await
|
||||
}
|
||||
def cleanRepo =
|
||||
($remove($select.all) inject BookmarkRepo /* >> repo.insert(bookmark) */ ).await
|
||||
|
||||
"The bookmark repo" should {
|
||||
|
||||
|
|
|
@ -16,5 +16,9 @@ object PlayApp {
|
|||
play.api.libs.concurrent.Akka.system
|
||||
}
|
||||
|
||||
def isDev = withApp { _.mode == Mode.Dev }
|
||||
def isDev = isMode(_.Dev)
|
||||
def isTest = isMode(_.Test)
|
||||
def isProd = isMode(_.Prod)
|
||||
def isServer = !(isDev || isTest)
|
||||
def isMode(f: Mode.type ⇒ Mode.Mode) = withApp { _.mode == f(Mode) }
|
||||
}
|
||||
|
|
|
@ -9,6 +9,9 @@ object WithDb {
|
|||
|
||||
lazy val fakeApp = FakeApplication(
|
||||
additionalPlugins = Seq("play.modules.reactivemongo.ReactiveMongoPlugin"),
|
||||
additionalConfiguration = Map("mongodb.db" -> "lila-test")
|
||||
additionalConfiguration = Map(
|
||||
"mongodb.db" -> "lila-test",
|
||||
"application.Global" -> "play.api.DefaultGlobal"
|
||||
)
|
||||
)
|
||||
}
|
||||
|
|
|
@ -10,7 +10,8 @@ final class Env(
|
|||
system: ActorSystem,
|
||||
hub: lila.hub.Env,
|
||||
appPath: String,
|
||||
isDev: Boolean) {
|
||||
isProd: Boolean,
|
||||
schedule: Boolean) {
|
||||
|
||||
private val settings = new {
|
||||
val CachedNbTtl = config duration "cached.nb.ttl"
|
||||
|
@ -44,12 +45,12 @@ final class Env(
|
|||
|
||||
lazy val rewind = Rewind
|
||||
|
||||
lazy val gameJs = new GameJs(path = jsPath, useCache = !isDev)
|
||||
lazy val gameJs = new GameJs(path = jsPath, useCache = isProd)
|
||||
|
||||
// load captcher actor
|
||||
system.actorOf(Props(new Captcher), name = CaptcherName)
|
||||
|
||||
if (!isDev) {
|
||||
if (schedule) {
|
||||
|
||||
val scheduler = new lila.common.Scheduler(system)
|
||||
import scala.concurrent.duration._
|
||||
|
@ -72,7 +73,7 @@ final class Env(
|
|||
bookmark = hub.actor.bookmark)
|
||||
|
||||
private def jsPath =
|
||||
"%s/%s".format(appPath, isDev.fold(JsPathRaw, JsPathCompiled))
|
||||
"%s/%s".format(appPath, isProd.fold(JsPathCompiled, JsPathRaw))
|
||||
}
|
||||
|
||||
object Env {
|
||||
|
@ -85,6 +86,7 @@ object Env {
|
|||
system = lila.common.PlayApp.system,
|
||||
hub = lila.hub.Env.current,
|
||||
appPath = app.path.getCanonicalPath,
|
||||
isDev = lila.common.PlayApp.isDev
|
||||
isProd = lila.common.PlayApp.isProd,
|
||||
schedule = lila.common.PlayApp.isServer
|
||||
)
|
||||
}
|
||||
|
|
|
@ -11,7 +11,8 @@ final class Env(
|
|||
config: Config,
|
||||
db: lila.db.Env,
|
||||
flood: lila.security.Flood,
|
||||
system: ActorSystem) {
|
||||
system: ActorSystem,
|
||||
schedule: Boolean) {
|
||||
|
||||
private val settings = new {
|
||||
val MessageMax = config getInt "message.max"
|
||||
|
@ -35,7 +36,7 @@ final class Env(
|
|||
|
||||
lazy val fisherman = new Fisherman(hookMemo, socket)
|
||||
|
||||
{
|
||||
if (schedule) {
|
||||
val scheduler = new lila.common.Scheduler(system)
|
||||
import scala.concurrent.duration._
|
||||
|
||||
|
@ -68,5 +69,6 @@ object Env {
|
|||
config = lila.common.PlayApp loadConfig "lobby",
|
||||
db = lila.db.Env.current,
|
||||
flood = lila.security.Env.current.flood,
|
||||
system = lila.common.PlayApp.system)
|
||||
system = lila.common.PlayApp.system,
|
||||
schedule = lila.common.PlayApp.isServer)
|
||||
}
|
||||
|
|
|
@ -9,7 +9,8 @@ final class Env(
|
|||
config: Config,
|
||||
db: lila.db.Env,
|
||||
hub: lila.hub.Env,
|
||||
system: ActorSystem) {
|
||||
system: ActorSystem,
|
||||
schedule: Boolean) {
|
||||
|
||||
private val ActorName = config getString "actor.name"
|
||||
private val SocketName = config getString "socket.name"
|
||||
|
@ -29,7 +30,7 @@ final class Env(
|
|||
hub = hub
|
||||
)), name = ActorName)
|
||||
|
||||
{
|
||||
if (schedule) {
|
||||
val scheduler = new lila.common.Scheduler(system)
|
||||
import scala.concurrent.duration._
|
||||
|
||||
|
@ -51,5 +52,6 @@ object Env {
|
|||
config = lila.common.PlayApp loadConfig "monitor",
|
||||
db = lila.db.Env.current,
|
||||
hub = lila.hub.Env.current,
|
||||
system = lila.common.PlayApp.system)
|
||||
system = lila.common.PlayApp.system,
|
||||
schedule = lila.common.PlayApp.isServer)
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ final class Env(
|
|||
hub: lila.hub.Env,
|
||||
ai: lila.ai.Ai,
|
||||
i18nKeys: lila.i18n.I18nKeys,
|
||||
isDev: Boolean) {
|
||||
schedule: Boolean) {
|
||||
|
||||
private val settings = new {
|
||||
val MessageTtl = config duration "message.ttl"
|
||||
|
@ -72,7 +72,7 @@ final class Env(
|
|||
|
||||
val animationDelay = AnimationDelay
|
||||
|
||||
if (!isDev) {
|
||||
if (schedule) {
|
||||
|
||||
val scheduler = new lila.common.Scheduler(system)
|
||||
import scala.concurrent.duration._
|
||||
|
@ -116,5 +116,5 @@ object Env {
|
|||
hub = lila.hub.Env.current,
|
||||
ai = lila.ai.Env.current.ai,
|
||||
i18nKeys = lila.i18n.Env.current.keys,
|
||||
isDev = lila.common.PlayApp.isDev)
|
||||
schedule = lila.common.PlayApp.isServer)
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ import scala.concurrent.Future
|
|||
import akka.actor.ActorSystem
|
||||
import scala.collection.JavaConversions._
|
||||
|
||||
final class Env(config: Config, system: ActorSystem) {
|
||||
final class Env(config: Config, system: ActorSystem, schedule: Boolean) {
|
||||
|
||||
private val ESHost = config getString "es.host"
|
||||
private val ESPort = config getInt "es.port"
|
||||
|
@ -24,7 +24,7 @@ final class Env(config: Config, system: ActorSystem) {
|
|||
loginfo("[search] ElasticSearch is running")
|
||||
}
|
||||
|
||||
{
|
||||
if (schedule) {
|
||||
val scheduler = new lila.common.Scheduler(system)
|
||||
import scala.concurrent.duration._
|
||||
|
||||
|
@ -38,5 +38,6 @@ object Env {
|
|||
|
||||
lazy val current = "[boot] search" describes new Env(
|
||||
config = lila.common.PlayApp loadConfig "search",
|
||||
system = lila.common.PlayApp.system)
|
||||
system = lila.common.PlayApp.system,
|
||||
schedule = lila.common.PlayApp.isServer)
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ final class Env(
|
|||
config: Config,
|
||||
captcher: ActorRef,
|
||||
system: ActorSystem,
|
||||
schedule: Boolean,
|
||||
db: lila.db.Env) {
|
||||
|
||||
private val settings = new {
|
||||
|
@ -41,7 +42,7 @@ final class Env(
|
|||
|
||||
lazy val userSpy = Store.userSpy _
|
||||
|
||||
{
|
||||
if (schedule) {
|
||||
val scheduler = new lila.common.Scheduler(system)
|
||||
import scala.concurrent.duration._
|
||||
|
||||
|
@ -62,5 +63,6 @@ object Env {
|
|||
config = lila.common.PlayApp loadConfig "security",
|
||||
db = lila.db.Env.current,
|
||||
system = lila.common.PlayApp.system,
|
||||
schedule = lila.common.PlayApp.isServer,
|
||||
captcher = lila.hub.Env.current.actor.captcher)
|
||||
}
|
||||
|
|
|
@ -13,18 +13,21 @@ import makeTimeout.short
|
|||
final class Env(
|
||||
config: Config,
|
||||
system: ActorSystem,
|
||||
schedule: Boolean,
|
||||
hub: lila.hub.Env) {
|
||||
|
||||
val scheduler = new lila.common.Scheduler(system)
|
||||
if (schedule) {
|
||||
val scheduler = new lila.common.Scheduler(system)
|
||||
|
||||
scheduler.message(5 seconds) {
|
||||
hub.socket.hub -> actorApi.Broom
|
||||
}
|
||||
scheduler.message(5 seconds) {
|
||||
hub.socket.hub -> actorApi.Broom
|
||||
}
|
||||
|
||||
scheduler.effect(2 seconds, "socket hub: refresh") {
|
||||
hub.socket.hub ? Ask(GetNbMembers) mapTo manifest[Seq[Int]] map { nbs ⇒
|
||||
NbMembers(nbs.sum)
|
||||
} pipeTo hub.socket.hub
|
||||
scheduler.effect(2 seconds, "socket hub: refresh") {
|
||||
hub.socket.hub ? Ask(GetNbMembers) mapTo manifest[Seq[Int]] map { nbs ⇒
|
||||
NbMembers(nbs.sum)
|
||||
} pipeTo hub.socket.hub
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -33,5 +36,6 @@ object Env {
|
|||
lazy val current = "[boot] socket" describes new Env(
|
||||
config = lila.common.PlayApp loadConfig "socket",
|
||||
system = lila.common.PlayApp.system,
|
||||
schedule = lila.common.PlayApp.isServer,
|
||||
hub = lila.hub.Env.current)
|
||||
}
|
||||
|
|
|
@ -10,7 +10,8 @@ final class Env(
|
|||
config: Config,
|
||||
db: lila.db.Env,
|
||||
hub: lila.hub.Env,
|
||||
system: ActorSystem) {
|
||||
system: ActorSystem,
|
||||
schedule: Boolean) {
|
||||
|
||||
private val settings = new {
|
||||
val PaginatorMaxPerPage = config getInt "paginator.max_per_page"
|
||||
|
@ -51,7 +52,7 @@ final class Env(
|
|||
}
|
||||
}
|
||||
|
||||
{
|
||||
if (schedule) {
|
||||
val scheduler = new lila.common.Scheduler(system)
|
||||
import scala.concurrent.duration._
|
||||
import akka.pattern.{ ask, pipe }
|
||||
|
@ -74,5 +75,6 @@ object Env {
|
|||
config = lila.common.PlayApp loadConfig "user",
|
||||
db = lila.db.Env.current,
|
||||
hub = lila.hub.Env.current,
|
||||
system = lila.common.PlayApp.system)
|
||||
system = lila.common.PlayApp.system,
|
||||
schedule = lila.common.PlayApp.isServer)
|
||||
}
|
||||
|
|
|
@ -1,60 +0,0 @@
|
|||
package lila.user
|
||||
|
||||
import tube.userTube
|
||||
import lila.db.Implicits._
|
||||
import lila.db.api._
|
||||
import lila.db.test.WithDb
|
||||
|
||||
import org.specs2.mutable.Specification
|
||||
|
||||
import play.api.test._
|
||||
import play.api.libs.json._
|
||||
|
||||
import org.joda.time.DateTime
|
||||
import org.scala_tools.time.Imports._
|
||||
|
||||
final class RepoTest extends Specification {
|
||||
|
||||
val user = User(
|
||||
id = "thibault",
|
||||
username = "Thibault",
|
||||
elo = 1200,
|
||||
nbGames = 10,
|
||||
nbRatedGames = 5,
|
||||
nbWins = 5,
|
||||
nbLosses = 5,
|
||||
nbDraws = 0,
|
||||
nbWinsH = 5,
|
||||
nbLossesH = 2,
|
||||
nbDrawsH = 0,
|
||||
nbAi = 3,
|
||||
isChatBan = false,
|
||||
enabled = true,
|
||||
roles = Nil,
|
||||
settings = Map.empty,
|
||||
bio = None,
|
||||
engine = false,
|
||||
toints = 0,
|
||||
createdAt = DateTime.now)
|
||||
|
||||
import makeTimeout.large
|
||||
|
||||
def cleanup {
|
||||
$remove($select.all) >> $insert(user) await
|
||||
}
|
||||
|
||||
"The user repo" should {
|
||||
// "idempotency" in new WithDb {
|
||||
// lazy val repo = cleanRepo
|
||||
// repo.find.byId(user.id) await timeout must_== user.some
|
||||
// }
|
||||
"date selector" in {
|
||||
"include" in new WithDb {
|
||||
cleanup
|
||||
$find.one(Json.obj(
|
||||
"ca" -> $gt($date(user.createdAt - RichInt(1).hours))
|
||||
)).await must_== user.some
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue