Disabling lazy load in Play application

2019-06-17 07:57发布

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.

4条回答
在下西门庆
2楼-- · 2019-06-17 08:34

You can run your application with testProd instead of run (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.

查看更多
做个烂人
3楼-- · 2019-06-17 08:35

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.

查看更多
Emotional °昔
4楼-- · 2019-06-17 08:37

Lazy loading only applies in dev mode (play run). Production mode is not lazy.

https://www.playframework.com/documentation/2.3.x/Production

查看更多
霸刀☆藐视天下
5楼-- · 2019-06-17 08:41

play start. This starts your app in production mode and loads onStart when on the app start.

查看更多
登录 后发表回答