GlobalSettings onStart only works after the first request

I need to run the code only once when I started the game server. When using the GlobalSettings.OnStart () function, I notice that the code is executed only after the first (http) request to the server. Any idea how I can run my code immediately after starting the server and before sending any request?

thanks

+4
source share
2 answers

This behavior when the application is in development mode, play run . When it is running in play start production mode, your onStart method will start immediately when the application starts before any requests.

+11
source

You can emulate this (or, I must say, bypass this unsuccessful dichotomous design) using this plugin, which, in my opinion, is useful and in general:

addSbtPlugin("com.jamesward" % "play-auto-refresh" % "0.0.11") (plugins.sbt)

And no, in fact it is not currently documented in the right place, since it works OnStart.

+1
source

Source: https://habr.com/ru/post/1497819/


All Articles