forked from lichess-org/lila
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEnv.scala
127 lines (110 loc) · 3.71 KB
/
Env.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
package lila.app
import akka.actor._
import com.typesafe.config.Config
final class Env(
config: Config,
system: ActorSystem,
appPath: String) {
val CliUsername = config getString "cli.username"
private val RendererName = config getString "app.renderer.name"
private val RouterName = config getString "app.router.name"
private val WebPath = config getString "app.web_path"
private val TimeagoLocalesPath = config getString "app.timeago_locales_path"
def timeagoLocalesPath = appPath + "/" + TimeagoLocalesPath
lazy val bus = lila.common.Bus(system)
lazy val preloader = new mashup.Preload(
lobby = Env.lobby.lobby,
history = Env.lobby.history,
featured = Env.game.featured,
relations = Env.relation.api,
leaderboard = Env.user.cached.topRatingDay.apply,
progress = Env.user.cached.topProgressDay.apply,
timelineEntries = Env.timeline.getter.userEntries _)
lazy val userInfo = mashup.UserInfo(
countUsers = () => Env.user.countEnabled,
bookmarkApi = Env.bookmark.api,
relationApi = Env.relation.api,
gameCached = Env.game.cached,
postApi = Env.forum.postApi,
getRatingChart = Env.user.ratingChart,
getRank = Env.user.ranking.get) _
if (config getBoolean "ai.stress") {
new AiStresser(Env.ai, system).apply
}
system.actorOf(Props(new actor.Renderer), name = RendererName)
system.actorOf(Props(new actor.Router(
baseUrl = Env.api.Net.BaseUrl,
protocol = Env.api.Net.Protocol,
domain = Env.api.Net.Domain
)), name = RouterName)
if (!Env.ai.isServer) {
loginfo("[boot] Preloading modules")
(Env.socket,
Env.site,
Env.tournament,
Env.lobby,
Env.game,
Env.setup,
Env.round,
Env.team,
Env.message,
Env.timeline,
Env.gameSearch,
Env.teamSearch,
Env.forumSearch,
Env.relation,
Env.report,
Env.notification,
Env.bookmark,
Env.pref,
Env.evaluation,
Env.chat,
Env.puzzle)
loginfo("[boot] Preloading complete")
}
if (Env.ai.isServer) println("Running as AI server")
if (config getBoolean "simulation.enabled") {
lila.simulation.Env.current.start
}
}
object Env {
lazy val current = "[boot] app" describes new Env(
config = lila.common.PlayApp.loadConfig,
system = lila.common.PlayApp.system,
appPath = lila.common.PlayApp withApp (_.path.getCanonicalPath))
def api = lila.api.Env.current
def db = lila.db.Env.current
def user = lila.user.Env.current
def security = lila.security.Env.current
def wiki = lila.wiki.Env.current
def hub = lila.hub.Env.current
def socket = lila.socket.Env.current
def message = lila.message.Env.current
def notification = lila.notification.Env.current
def i18n = lila.i18n.Env.current
def game = lila.game.Env.current
def bookmark = lila.bookmark.Env.current
def search = lila.search.Env.current
def gameSearch = lila.gameSearch.Env.current
def timeline = lila.timeline.Env.current
def forum = lila.forum.Env.current
def forumSearch = lila.forumSearch.Env.current
def team = lila.team.Env.current
def teamSearch = lila.teamSearch.Env.current
def ai = lila.ai.Env.current
def analyse = lila.analyse.Env.current
def mod = lila.mod.Env.current
def monitor = lila.monitor.Env.current
def site = lila.site.Env.current
def round = lila.round.Env.current
def lobby = lila.lobby.Env.current
def setup = lila.setup.Env.current
def importer = lila.importer.Env.current
def tournament = lila.tournament.Env.current
def relation = lila.relation.Env.current
def report = lila.report.Env.current
def pref = lila.pref.Env.current
def evaluation = lila.evaluation.Env.current
def chat = lila.chat.Env.current
def puzzle = lila.puzzle.Env.current
}