By default your Play application will be fully started (compiled, Global
's onStart
called, etc.) only after you do http request to it.
Is there a way to disable this lazy load and make Play app compile code and do startup once application process is run?
PS: I am using Play 2.3.
UPDATE: As Ryan pointed out lazy load happens only in dev. mode. Nevertheless I still need to disable it, despite this is relevant only to apps running in dev. mode.
You can run your application with
testProd
instead ofrun
(in the current 2.5 version). This starts your application in prod mode instead of dev.If you're running from IntelliJ rather than the Play console, you need to create a new run config, choose SBT Task, and in the Tasks section enter
testProd
.As Ryan explained it's for dev only.
TIP: IntelliJ Idea has a Play support, by default it opens the new browser window after running in dev mode, which initializes compilation automatically.
Quite sure you can do the same with simple shell script / batch file.
Lazy loading only applies in dev mode (
play run
). Production mode is not lazy.https://www.playframework.com/documentation/2.3.x/Production
play start
. This starts your app in production mode and loadsonStart
when on the app start.