Disabling lazy load in Play application
Asked Answered
G

4

8

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.

Gopher answered 13/11, 2014 at 21:15 Comment(1)
I don't think there is an easy way to disable this. The play server starts in dev mode on the first request so that it can recompile when you refresh the page. You may have to employ some trickery like @biesior is suggesting.Anomalous
W
1

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

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

Webfooted answered 13/11, 2014 at 21:35 Comment(1)
Hmm, ok. I wanted this to ease debugging of some part of my app, so, guess the question is still relevant - is there a way to disable it in dev. mode?Gopher
R
1

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.

Raycher answered 13/11, 2014 at 21:42 Comment(0)
U
1

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.

Unrounded answered 6/7, 2016 at 14:1 Comment(0)
C
0

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

Canonist answered 29/3, 2015 at 9:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.